Title: Insert a Row in a Datagrid without mentioning column names Post by: aemalsayer on August 12, 2013, 10:17:43 PM I want to add a row into a datagrid without mentioning the Column names. Right now I can Insert a row by using the following syntax:
$('#dg').datagrid('insertRow',{ index: 1, // index start with 0 row: { name: 'new name', age: 30, note: 'some messages' } }); But I want it to be like the following: $('#dg').datagrid('insertRow',{ index: 1, // index start with 0 row: { 'new name', 30, 'some messages' } }); I want this feature to create a function which should be able to dynamically add sub totals to as many columns of a datagrid as I give it as a parameter. Or, please show me how to add an array to a row of a datagrid like following: var varRow = new Array ('new name', 30, 'some messages'); $('#dg').datagrid('insertRow',{ index: 1, // index start with 0 row: { varRow } }); Title: Re: Insert a Row in a Datagrid without mentioning column names Post by: stworthy on August 15, 2013, 01:22:08 AM When insert a row to datagrid, the 'column-value' mapping must be specified. If you want to insert a raw array such as ('new name', 30, 'some messages'), this array must be converted to {name:'new name',age:30,note:'some messages'} before insert to datagrid. You could extend a new method to do so.
Code: $.extend($.fn.datagrid.methods,{ Code: var row = ['new name', 30, 'some messages']; |