Certainly.
I have a datagrid made like this:
var identifier = some table
var dataURL = some url from which I fetch data
var getURL = some url from which I get detailview
$(identifier).datagrid({
striped: true,
method: 'get',
pagination: "true",
pageSize: 20,
fitColumns: true,
loadFilter: function(data) {
return {rows: data.response, total: data.total}
},
url: 'dataURL',
view: detailview,
detailFormatter:function(index,row){
return '<div class="ddv"></div>'; k
},
onExpandRow:function(index,row){
var ddv = $(this).datagrid('getRowDetail',index).find('div.ddv');
$.get(getURL, {slug: row.slug, index: index}, function(data){
$(ddv).html(data);
$(identifier).datagrid('fixRowHeight');
$(identifier).datagrid('fixDetailRowHeight', index);
}, "html");
}
});
The code that creates a new row is this:
function ui_datagrid_newRow(identifier) {
$(identifier).datagrid('appendRow',{
isNewRecord:true
});
var index = $(identifier).datagrid('getRows').length - 1;
$(identifier).datagrid('expandRow', index);
$(identifier).datagrid('selectRow', index);
}
If the table is empty when I call "function ui_datagrid_newRow", I get this error:
rows is undefined
for(var i=0; i<rows.length; i++) {
on line 60 of jquery.datagrid-detailview.js
Does this help?