Some other bread-and-butter functions when working with Gridpanels:
function deleteRecords(grid) {
var selected = grid.getSelectionModel().getSelections();
for (var i = 0; i < selected.length; i++) {
grid.store.remove(selected[i]);
}
}
function insertRecord(grid) {
grid.stopEditing();
var iNextIndex = grid.getStore().getCount();
grid.insertRecord(iNextIndex, {});
grid.getView().focusRow(iNextIndex);
grid.startEditing(0, iNextIndex);
}
/******************************************************************
* Manages firing off the NoteWindow for each record note
*********************************************************************/
var cellClick = function(grid, rowIndex, columnIndex, e) {
var t = e.getTarget();
var record = grid.getStore().getAt(rowIndex); // Get the Record
var columnId = grid.getColumnModel().getColumnId(columnIndex); // Get column id
// act on clicks to the Notes cell
if (t.className == 'noteEdit' && columnId == 'Note') {
Ext.Msg.prompt('Notes:', t.embedded, function(btn, text) {
if (btn == 'ok') {
// process text value...
if (text != '') {
record.set('Note', text);
}
}
});
}
}
<ext:Button ID="btnAddRow" runat="server" Icon="Add" Text="Add Line">
<Listeners>
<Click Handler="insertRecord(#{TimeCardGrid});" />
</Listeners>
<ToolTips>
<ext:ToolTip Target="btnAddRow" Html="Adds an empty line to the current weekly chart." HeaderAsText="true" Title="Add Line Button">
</ext:ToolTip>
</ToolTips>
</ext:Button>