Skip to content

Instantly share code, notes, and snippets.

@gamejunkie
Created December 14, 2012 21:40
Show Gist options
  • Save gamejunkie/4288890 to your computer and use it in GitHub Desktop.
Save gamejunkie/4288890 to your computer and use it in GitHub Desktop.
DGrid renderCell Example
postCreate: function(){
// Create a new constructor by mixing in the components
var CustomGrid = declare([ Grid, Keyboard, Selection, GridRegistry ]);
var columns = [
{
label : ' ',
field : 'deletelink',
renderCell: lang.hitch(this, function(object, value, node, options) {
var deleteButton = new Button(
{
label: "D",
onClick: lang.hitch(this, function(state) {
var str = object["links"]["delete"];
this.deleteClient(str);
})
});
deleteButton.placeAt(node);
}),
sortable : false
},
{
label : 'ID',
field : 'ID',
sortable : true
}, Editor({
label : 'Client Name',
field : 'clientname',
sortable : true,
autoSave: true},
"text",
"dblclick")
];
// Now, create an instance of our custom grid which
// have the features we added!
var grid = new CustomGrid({
columns:columns,
selectionMode: "single", // for Selection; only select a single row at a time
cellNavigation: false // for Keyboard; allow only row-level keyboard navigation
}, "clientGrid");
grid.on("dgrid-datachange", lang.hitch(this, function(evt) {
this.updateClient(evt.rowId, evt.value);
}));
// Run any parent postCreate processes - can be done at any point
this.inherited(arguments);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment