Code:
/* load existing orders in a grid */
loadOrders: function(){
// create the datastore
var ds = new Ext.data.Store({
// load using HTTP
proxy: new Ext.data.HttpProxy({url: '/orders/orders', method: 'GET'}),
// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have a "order" tag
record: 'order'
}, [
{name: 'OrderNo', mapping: 'OrderNo'},
{name: 'Status', mapping: 'Status'},
{name: 'ExamDate', mapping: 'ExamDate'},
{name: 'PatientName', mapping: 'PatientName'},
{name: 'Radiologist', mapping: 'Radiologist'},
{name: 'Site', mapping: 'Site'},
{name: 'Technician', mapping: 'Technician'},
{name: 'ReferringMD', mapping: 'ReferringMD'}
])
});
var cm = new Ext.grid.ColumnModel([
{width:30, renderer: cr, resizable:false},
{header: "Order No", width:70, dataIndex: "OrderNo"},
{header: "Status", width:70, dataIndex: "Status"},
{header: "Exam Date", width:150, dataIndex: "ExamDate"},
{header: "Patient Name", width:150, dataIndex: "PatientName"},
{header: "Radiologist", width:150, dataIndex: "Radiologist"},
{header: "Site", width:70, dataIndex: "Site"},
{header: "Technician", width:70, dataIndex: "Technician"},
{id: 'g-rmd', header: "Referring MD", width:150, dataIndex: "ReferringMD"}
]);
cm.defaultSortable = true;
ordersGrid = new Ext.grid.Grid('order-grid', {
ds: ds,
cm: cm,
autoExpandColumn: 'g-rmd',
selModel: new Ext.grid.RowSelectionModel({multipleSelect:true})
});
ordersGrid.render();
var gridFoot = ordersGrid.getView().getFooterPanel(true);
// add a paging toolbar to the grid's footer
var paging = new Ext.PagingToolbar(gridFoot, ds, {
pageSize: 10,
displayInfo: true,
displayMsg: 'Displaying orders {0} - {1} of {2}',
emptyMsg: "No orders to display"
});
// add the detailed view button
paging.add('-', {
text: 'View Details',
cls: 'x-btn-text-icon'
});
ds.load({params:{start:0, limit:10}});
ordersGrid.getSelectionModel().selectFirstRow();
//custom renderer for first column
function cr(){
return "<input type='checkbox' class='chk'>";
}
}
I am really stuck here running out of ideas, don't know how to force selection of a row clicking on a checkbox. :oops: Any help is much appreciated.