i am having difficulty with a grid panel on button click data json store update

28 views
Skip to first unread message

nadeemshafi9

unread,
Mar 30, 2009, 7:08:44 PM3/30/09
to PHP-Ext
I need to load my gridview with new json data when i click my button
but it just makes it go blank but does insert teh column model

here is an abstract of my update button and function they trigger the
change but the grid view is empty

$func = new PhpExt_Handler(
PhpExt_Javascript::stm('
var colModel = new Ext.grid.ColumnModel([
{ header: "title", width: 160, sortable: true},
{ header: "name", width: 75, sortable: true},
{ header: "filename", width: 75, sortable: true}
]);

var store = new Ext.data.JsonStore({
url: "http://nadeemdesktop/services/service.php?
service=Music&invoke=byNameJSON&name_arg=The%20Beegies",
root: "music.file"
});
Ext.getCmp("grid1").reconfigure(store, colModel);
')
);

$simple->addButton(PhpExt_Button::createTextButton("Save", $func));


AND HERE IS MY GRID LOADED WITH JSON DATA IT WORKS


////////////////////// GRID


$PageSize = 10;

$changeRenderer = PhpExt_Javascript::functionDef("change","if(val > 0)
{
return '<span style=\"color:green;\">' + val + '</span>';
}else if(val < 0){
return '<span style=\"color:red;\">' + val + '</span>';
}
return val;",array("val"));
$pctChangeRenderer = PhpExt_Javascript::functionDef("pctChange","if
(val > 0){
return '<span style=\"color:green;\">' + val + '%</span>';
}else if(val < 0){
return '<span style=\"color:red;\">' + val + '%</span>';
}
return val;",array("val"));

$reader = new PhpExt_Data_JsonReader();
$reader->setRoot("music.file");
$reader->addField(new PhpExt_Data_FieldConfigObject("title"));
$reader->addField(new PhpExt_Data_FieldConfigObject("name"));
$reader->addField(new PhpExt_Data_FieldConfigObject("filename"));

// Store
$store = new PhpExt_Data_Store();
$store->setUrl('http://nadeemdesktop/services/service.php?
service=Music&invoke=allJSON')
->setReader($reader)
->setBaseParams(array("limit"=>$PageSize));


// ColumnModel
$colModel = new PhpExt_Grid_ColumnModel();
$colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn
("title","title",null,160, null, null, true, true))
->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn
("name","name",null,75,null,null, true, true))
->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn
("filename","filename",null,75,null,null, null, true));

// Grid
$grid = new PhpExt_Grid_GridPanel();
$grid->setStore($store)
->setId('grid1')
->setColumnModel($colModel)
->setStripeRows(true)
->setHeight(350)
->setWidth(600)
->setTitle("Json Grid");


$paging = new PhpExt_Toolbar_PagingToolbar();
$paging->setStore($store)
->setPageSize($PageSize)
->setDisplayInfo("Topics {0} - {1} of {2}")
->setEmptyMessage("No topics to display");
$grid->setBottomToolbar($paging);
Reply all
Reply to author
Forward
0 new messages