PDA

View Full Version : Check Selection Model, on CRUD the multiple select header does not create a submit.



pjamrisk
3 Aug 2010, 12:31 AM
Hello again guys,
I been playing with the editor Grid for about 2 weeks now, and I am still on the learning curve even though I don't seem to find all the configs for it. Anyways, I created a checkbox selection model element for the grid, and I want to be able to send an update (PUT) for all the records displayed.
When I click on the box, it does select all the fields as expected, but when I hit my submit button, I don't get any response in firebug. Now, when I do a single select, it does generate a PUT event, which I capture on the back-end for edition.

Here is what I got so far on my code.


App.sm = new Ext.grid.CheckboxSelectionModel({
// inputValue: '1',
singleSelect: false,
checkOnly: true,
dataIndex: 'visinspection',
editor: new Ext.form.Checkbox({
})
});
var colModel = new Ext.grid.ColumnModel({
columns: [new Ext.grid.RowNumberer(),
App.sm,
...
]
});

// create yellowsheet.Grid instance (@see UserGrid.js)
var minorPMGrid = new App.minorPM.grid({
store: datastores.searchBar,
cm: colModel,
sm: App.sm,
plugins: [App.minorPM.filters],
clicksToEdit: 1,
listeners: {
rowclick: function(g, index, ev) {
var rec = g.store.getAt(index);
}
}
});



The rest of teh code is standard to add the this grid into a form panel. I am using an onSave handler which does the following:


onSave : function(btn, ev) {
if (Ext.getCmp('minorPMGrid_id').getForm().isValid()){
//Make sure to grab the elements of the form first.
this.store.baseParams = {
pm: Ext.getCmp('pm_id').getValue(),
date: document.getElementById('date_id').value,
notes: document.getElementById('notes_id').value,
lookup: 'no' //this is to determine if it is a search or not with the put method.
};
this.store.save();
//Clear the search box.
var s = Ext.getCmp('search_id');
s.setValue('');
this.store.removeAll(); // This clears the grid after the new items have been saved (submitted)
App.gridForm.getForm().reset(); //this resets the selected fields above.
}else {
//The form has some missing fields, so we do nothing for now and let the user know
Ext.MessageBox.show ({title: 'Error !',
msg: 'Please make sure all required fields are filled out.'});
//Function below autocloses the messagebox
(function() {
Ext.MessageBox.hide();
}).defer(3300);
}
}



any pointers or examples to look at will be greatly appreciated as always. In the meantime, I will be reading the API to see if I find another solution.
Thanks again,

Patrick

Condor
3 Aug 2010, 12:36 AM
You don't want an Ext.grid.CheckboxSelectionModel, you want an Ext.ux.grid.CheckColumn (from ext/examples/ux).

pjamrisk
3 Aug 2010, 12:45 AM
Condor,
Thanks for your quick reply. I do have a setup with the ux model as well, but that one does not have a multiple select option for the header, or does it? is there an example somewhere for it?

Thanks,
Patrick

Condor
3 Aug 2010, 12:48 AM
No it doesn't by default, but you could add a header checkbox.

pjamrisk
3 Aug 2010, 12:54 AM
Condor,
Ok, how do I call it on the "header:" config. If I try it as a new instance of checkbox it returns back to me as an object instead of the checkbox.

[--edit--]
I think I am just going to stop for today :). I been looking at this code all night and I should be able to solve such a simple thing. Anyways, Just wanted ot thank you Condor. If I have issues tonight with the header i'll post again here.

Thanks again,
Patrick