jQuery UI Widgets › Forums › Grid › add rows using addrow method
Tagged: addrow several multiple, angular grid, angularjs, jquery datagrid, jquery grid, jqwidgets, jqxGrid ;
This topic contains 2 replies, has 3 voices, and was last updated by ismaelnascimento 6 years, 6 months ago.
-
Author
-
Hi, I have this grid displaying some plain mysql table: id (int) , name varchar(10)
Users can add records to this table using my grid (php code server side).
they can add only one record or several.I have problems refreshing the grid when multiple records are inserted. ( when only 1 record is inserted everything works fine)
My serverside php script ends with something like this:
<?php
$pdo->Query( ‘select * from myTable where id IN ( … , … , … , … )’ ); // supose the query is OK.
$Results = array();
while( $row = $pdo->getRow() ) {
$Results[‘data’][] = $row;
}
$Results[‘status’] = ‘ok’;
die( json_encode($Results) );?>
And my client side (.js)
$.ajax({
url: ‘myScript.php’, data: {howManyRecords: $(‘#recs’).val(), name: $(‘#name’).val() }, method: ‘post’,
success: function( response ) {
var obj = $.parseJSON(response);// let’s collect rows returned
var rows = new Array();
$.each( obj.data, function( k, v ) {
rows.push(v);
});// refresh grid
$(‘#jqxGrid’).jqxGrid(‘addrow’, null, rows);// close modal window
$(‘#jqxWindow’).jqxWindow(‘hide’);
}
})My grid refreshes only one record. But if I reload the page ( F5 ), all records are shown.
What am I missing ???
thanks in adv
hi omargaro,
We have online demo: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/createremoveupdatedata.htm?arctic which demonstrates how to add multiple rows at once in jqxGrid. You may take a look at it and follow the same approach. Also, adding multiple rows on the client side does not depend on the server side.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/@ViewChild(‘myGrid’) grid: jqxGridComponent;
this.grid.columns = [
{
datafield: ‘CODE’,
text: ‘Code’,
},
{
datafield: ‘DESCRIPTION’,
text: ‘Description’
}
];this.grid.addrow(null,
{ “CODE”: 999,
“DESCRIPTION”: “My Description”
}
); -
AuthorPosts
You must be logged in to reply to this topic.