ExtJs dataview refresh problem

by admin on February 20th, 2012

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

By using this code your dataview automatically be refreshed.

NOTE: The response only come in the pure json format

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.

$result= mysql_query($query);
$json_data['templateItems'] = array();
while($row= mysql_fetch_assoc($result)){
$json_data['templateItems'][]= $row;
}
echo json_encode($json_data);exit;
Data view 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(
 '',
 '
<div>{templatecat_name}</div>
',
 ''
 ),
 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'
 })

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>