Saturday, April 3, 2010

ExtJs dataview refresh problem

[code]Ext.getCmp(dataview id).getStore().load({params:{}});
or
Ext.getCmp(dataview id).getStore().reload();

By using this code your dataview automatically be refreshed.[/code]
[b]NOTE: The response only come in the pure json format[/b]

If you will use this in PHP for fetching the data for
dataview you must declare $json_data['templateItems'][]= $row;
in case of no result found. Otherwise your data view not working correctly.
[code]
$result= mysql_query($query);
$json_data['templateItems'] = array();
while($row= mysql_fetch_assoc($result)){
$json_data['templateItems'][]= $row;
}
echo json_encode($json_data);exit;[/code]

[b]Data view code[/b]
[code]new Ext.DataView({
store: new Ext.data.JsonStore({
url: 'connect.php',
baseParams: {moduleId:moduleId,action:'doAction',activity:'getTemplateCats'},
autoLoad:false,
root: 'templatecats',
fields: ['templatecat_name','id']
}),
tpl: new Ext.XTemplate(
'',
'
{templatecat_name}
',
'
'
),
listeners : {
click : function(dataView,index,node,e) {
var record = dataView.getRecord(node);
var cat_name =record.get("templatecat_name");
var cat_id =record.get('id');

Ext.getCmp('cat_id_temp_s').setValue(cat_id);
Ext.getCmp('newCardS').getLayout().setActiveItem(1);
Ext.getCmp('s-templates-items').getStore().load(
{params:{moduleId:moduleId,action:'doAction',
cat_id:cat_id,templatelocation:'subjective',activity:'getTemplates'}});
}
},
id:'s-templates',
autoHeight:true,
multiSelect: true,
overClass:'x-view-over',
itemSelector:'div.thumb-wrap',
emptyText: 'No templates to display'
})[/code]

No comments:

Post a Comment