Loading a window on clicking of a row in the grid - extjs

Hi i have a grid with values ,
when i click a the row in the grid i need to
open a window with all the values in that row.
I have done till loading a grid and populating values in the grid. I am working in ext js for the last two weeks can any one tell me how to proceed further
My Code:
function loadcolleaguesVal(jsonContent){
var localJson = Ext.util.JSON.decode(jsonContent);
colleagueGridJS=Ext.util.JSON.decode(localJson.ColleagueInfo);
colleagueGridDataJS=Ext.util.JSON.decode(localJson.colData);
var caseReGridData= new Ext.data.JsonStore({
autoLoad :true,
fields: ["NAME",
"TOTAL_CASES_ALLOWED",
"TOTAL_OPEN_CASES",
"CLIENT_TEAM_CASES_ALLOWED",
"CLIENT_TEAM_TOTAL_CASES",
"PAY_AUTH_MAX",
"DAYS_MAX",
"LUMP_SUM_MAX",
"DENIAL_ADMIN",
"DENIAL_CLINICAL"],
storeId :'ColleagueInfo',
data : colleagueGridDataJS,
root : 'data',
listeners : {
load : colleagueGridListerner
}
});
}
function colleagueGridListerner(){
nucleus.tools.master(colleagueGridJS,"NonEditableGrid","colleagueGrid",caseReGridData,"twoFields");
panelForPage.addButton({
text:'Add new colleague',
type:'Submit',
name:'btnGo',
handler:function()
{
showColleagueSetup();
}
});
Ext.getCmp('colleagueCenter').add(panelForPage);
Ext.getCmp('colleagueGrid_Grid').setHeight(145);
Ext.getCmp('colleagueGrid_Grid').doLayout();
tabPanel.doLayout();
Ext.getCmp("colleagueGrid_Grid").collapse();
}

I can't see grid into your code but you can add selection model into grid:
var grid = new Ext.grid.GridPanel({
.
.
.
sm:new Ext.grid.RowSelectionModel({singleSelect:true}),
.
.
});
and add event:
grid.getSelectionModel().on('rowselect', function (selModel, rowIndex, record ) {
//Your row selected data is:
var data = record.data;
//Open window code
...
});

Related

Combobox inside Extjs editor grid panel while populating is invisible sometimes

Hi all I am using Extjs 3.4 my problem is I have one editor grid panel
and inside panel I have one department combobox. So, in first page I
have search grid and on click of grid I am coming to this page and on
load using ajax I am populating combobox value in grid panel. But sometimes
values are not coming, means it is invisible and only after clicking on that
combobox it is appearing. Can some body explain what is the problem.
Thanks in advance, I hope will get reply soon.
While populating I am calling one ajax which is populating values in grid but
there is no issue with other columns, only with combobox it is invisible sometimes
Ext.util.Format.comboRenderer = function(Departmentscombo){
return function(value){
var record = combo.findRecord(combo.valueField || combo.displayField, value);
return record ? record.get(combo.displayField) : combo.valueNotFoundText;
}
}
Ext.grid.ComboColumn = Ext.extend(Ext.grid.Column, {
constructor: function(cfg){
Ext.grid.ComboColumn.superclass.constructor.call(this, cfg);
this.renderer = Ext.util.Format.comboRenderer(this.editor.field ?
this.editor.field : this.editor);
}
});
Ext.apply(Ext.grid.Column.types, {
combocolumn: Ext.grid.ComboColumn
});
var DepartmentsJReader = new Ext.data.JsonReader
({ root: 'data', id: 'mastercode' },
[{ name: 'mastercode' }, { name: 'description'}]);
Departments_store = new Ext.data.Store
({
proxy: new Ext.data.HttpProxy(
{ url: '', method: 'GET' }),
reader: DepartmentsJReader, autoLoad: true,
listeners:
{
load: function () {
var rec = new Departments_store.recordType({ mastercode:'-', description: '-' });
rec.commit();
Departments_store.insert(0, rec);
Departments_store.commitChanges();
}
}
});

EXT JS 3.0 Grid , Show column when data is not empty

Is there a way to show columns only when they have data in them?
var grid = new Ext.grid.GridPanel({
width:938,
height:auto,
store: store,
renderTo: 'Div',
// grid columns
columns:[
{coloum1},
{coloum2},
{coloum3},
{coloum4} ] }};
// Only show column when it has data
In the store config use the load event.
var myStore = new JsonStore({
.. config..
listener :
{
'load': function(){
/*
Code to check if the column data is empty - returns true/false
*/
if(isEmpty)
{
mygrid.getColumnModel().setHidden(colIndex,true);
}
}
});
Relevant API doc here
This is blind coding and written without testing. But it should work.

EXTJS GridPanel Inside Window Is Not Loading Updated Data From Store When Window is Re-Opened

I have an EXT form that opens a window containing an GridPanel where the data store needs to get updated each time the form is submitted. The grid displays a list of files that are uploaded from the client computer. All of this works fine until I close the window and select a different group of files. The problem I am having is when the window containing the grid is closed and then re-opened, it is displaying the first set of files loaded previously instead of the new list of files submitted from the form. Hopefully this makes sense.
I have tried grid.getView().refresh() but that doesn't update the grid. Below is my code for the window, form, grid, and JSON store. If anyone has seen this before I would sure appreciate some advice. (apologies for the code formatting...had a lot of trouble getting it to be readable this text box)
//window that holds grid
SPST.window.POGCheckInWindow = Ext.extend(SPST.window.WindowBaseCls, {
id: 'POGCheckInWindow'
,initComponent:function() {
var config = {
title: 'Check In POG Files'
,width : 1000
,height : 500
,maximizable: false
,shadow : false
,closeable: true
,closeAction: 'hide'
,items: [{
xtype : 'checkin_results_grid'
,id : 'POGCheckInGrid'
,height : 450
,width : 990
,frame : true }
]};
Ext.apply(this, Ext.apply(this.initialConfig, config));
SPST.window.POGCheckInWindow.superclass.initComponent.apply(this, arguments);
}
});
Ext.reg('pog_checkin_window',SPST.window.POGCheckInWindow);
//function to submit the form, load the store and open the window containing the gridpanel
checkin:function() {
if (this.getForm().isValid()){
this.getForm().submit({
url: 'components/POG.cfc?method=uploadPOGTemp' + '&dsn=' + SPST_dsn
,method: 'GET'
,scope:this
,success: function(form, action){
var chkinwin = new SPST.window.POGCheckInWindow();
Ext.getCmp('POGCheckInGrid').getStore().load({params: {dsn: SPST_dsn,
pogfiles: action.result.pogfiles, project_id: action.result.project_id}
,callback: function(rec, options, success){
Ext.getCmp('POGCheckInGrid').getView().refresh();
}
});
chkinwin.show();
}
,failure:this.showError
,waitMsg:'Uploading files...'
});
}
}
// create the data store for grid
var chkstore = new Ext.data.JsonStore({
// JsonReader configuration
root : 'jsonlist'
,fields : chkfields
,id : 'chkstoreid'
// JsonStore configuration
,autoLoad : true
,remoteSort : true
,autoDestroy: true
,sortInfo: {
field: 'POGNAME',
direction: 'ASC'
}
,url : 'components/POG.cfc?method=getPOGTempFiles' + '&dsn=' + SPST_dsn
});
//grid that loads inside ext window
SPST.grid.POGCheckInGrid = Ext.extend(SPST.grid.GridPanelBaseCls, {
view: new Ext.grid.GridView({
getRowClass: function(rec, idx, rowPrms, ds)
{
return rec.data.VERSION_DSC === 'INVALID VERSION#' ? 'invalid-cls' : '';
}
}),
initComponent : function() {
var config = {
colModel : chkcolModel
,selModel : chkselModel
,store : chkstore
,autoDestroy: true
,xtype : 'checkin_results_grid'
,buttons: [
{
text: 'Upload'
,handler: this.loadPOGCheckin
,scope : this
},
{
text: 'Cancel'
,handler: this.checkinwindowclose
,scope : this
}
]
}
Ext.apply(this, Ext.apply(this.initialConfig, config));
SPST.grid.POGCheckInGrid.superclass.initComponent.apply(this, arguments);
}
,onRender : function() {
this.getBottomToolbar().bindStore(chkstore);
SPST.grid.POGCheckInGrid.superclass.onRender.apply(this, arguments);
}
From what I understood, you don't need to only refresh the view, but also reload the store according to the different set of files that you selected..
So, instead of doing
grid.getView().refresh() use grid.getStore().reload([new-options-if-required]);.. This will reload the store according to the options passed, if any, or reload the store according to the last load options.

extjs dataview issue

I am creating a report making tool. I will be dragging/resizing panels inside a panel container. When i click save button, i am passing the size and position of panels and based on that an xhtml report will be generated. I have a dataview on the left side. Each time a report is generated i need to show that report on dataview. Without using any database how this can be done? Any help would be appreciated.
Do one thing, create a store with fields "size", "report_data" and "position".
var store = new Ext.data.JsonStore({
id : 'panel_store',
fields : ['size', 'position', 'report_data']
});
Create a template for each report (some other data can be added here):
var template = new Ext.XTemplate(
'<div class="reports_container"><tpl for=".">',
'<div class="report">{report_data}</div>','</tpl></div>'
);
template.compile();
Create a dataview with template and store:
var dataView = new Ext.DataView({
itemSelector : 'div.report', // Required
style : 'overflow:auto',
multiSelect : true,
store : store,
tpl : template
});
Add the dataview in you main panel:
var mainPanel = new Ext.Panel({
id : 'main_panel',
items : dataView
});
Whenever you generate a new report, create a new Ext.Record:
var ReportRecord = Ext.data.Record.create([
{ name: 'size' },
{ name: 'position' },
{ name: 'record_type' }
]);
var newRec = new ReportRecord({
size : '100',
position : 'some position',
report_data : 'some data'
});
store.add(newRec);
store.on('add', function() {
dataView.refresh();
}, this);
Is this what you wanted? However, this code isn't tested anywhere.

How to apply seriesStyles to piechart in ExtJs dynamically

Am trying to set 'seriesstyles' to piechart dynamically from the JSON data. When the 'oneWeekStore' loads the JSON data, I wish to iterate through the 'color' of each record and setSeriesStyles dynamically to PieChart. Below is the snippet.
var oneWeekStore = new Ext.data.JsonStore({
id:'jsonStore',
fields: ['appCount','appName'],
autoLoad: true,
root: 'rows',
proxy:storeProxy,
baseParams:{
'interval':'oneWeek',
'fromDate':frmDt.getValue()
},
listeners: {load: {
fn:function(store,records,options) {
/*I wish iterate through each record,fetch 'color'
and setSeriesStyles. I tried passing sample arrays
as paramater to setSeriesStyles like
**colors= new Array('0x08E3FE','0x448991','0x054D56');
Ext.getCmp('test12').setSeriesStyles(colors)**
But FF throws error "this.swf is undefined". Could
you please let me know the right format to pass as
parameter. */
}
});
var panel = new Ext.Panel{
id: '1week', title:'1 week',
items : [
{ id:'test12',
xtype : 'piechart',
store : oneWeekStore,
dataField : 'appCount',
categoryField : 'appName',
extraStyle : {
legend:{
display : 'right',
padding : 5,
spacing: 2, font :color:0x000000,family:
'Arial', size:9},
border:{size :1,color :0x999999},
background:{color: 0xd6e1cc}
} } } ] }
My JSON data looks below:
{"success":true,"rows":[{"appCount":"9693814","appName":"GED","color":"0xFB5D0D"},{"appCount":"5731","appName":"SGEF"","color":"0xFFFF6B"}]}
Your guidance is highly appreciated
You have a classic race condition there - your setting an event in motion that relies on a Component who's status is unknown.
The event your setting off is the loading of the data Store, when that has finished loading it is trying to interact with the Panel, but at that point we don't know if the Panel has been rendered yet.
Your best bet is to make one of those things happen in reaction to the other, for example:
1 ) load the store
2 ) on load event fired, create the panel
var oneWeekStore = new Ext.data.JsonStore({
id:'jsonStore',
...,
listeners: {
load:function(store,records,options) {
var panel = new Ext.Panel({
...,
seriesStyles: colors,
...
});
}
}
});
or
1 ) create the panel (chart)
2 ) on render event of the panel, load the store (remove autoLoad:true)
var panel = new Ext.Panel({
id: '1week',
...,
listeners: {
render: function(pnl){
oneWeekStore.load();
}
}
});
Hope that helps.

Resources