jQuery UI Widgets › Forums › Grid › How to delete row from grid
This topic contains 3 replies, has 2 voices, and was last updated by farhadidrees 13 years, 2 months ago.
-
Author
-
Hi Guys..
i want to delete selected row in datagrid how to do it?i have this function which is only showing data in grid and also updating data from datagrid..
$(document).ready(function () {
// prepare the data
var data = {};
var theme = ‘classic’;var source =
{
datatype: “json”,
datafields: [
{ name: ‘name’},
{ name: ‘id’}
],
id: ‘id’,
url: ‘data_qualification.php’,
updaterow: function (rowid, rowdata, commit) {
// synchronize with the server – send update command
var data = “update=true&name=” + rowdata.name;// + “&LastName=” + rowdata.LastName + “&Title=” + rowdata.Title;
/// data = data + “&Address=” + rowdata.Address + “&City=” + rowdata.City + “&Country=” + rowdata.Country + “&Notes=””;
data = data + “&id=” + rowdata.id;$.ajax({
dataType: ‘json’,
url: ‘data_qualification.php’,
data: data,
success: function (data, status, xhr) {
// update command is executed.
commit(true);
}
});
}
};var dataAdapter = new $.jqx.dataAdapter(source);
// initialize jqxGrid
$(“#jqxgrid”).jqxGrid(
{
width: 280,
height: 350,
selectionmode: ‘singlecell’,
source: dataAdapter,
theme: theme,
editable: true,
columns: [
{ text: ‘ID’, editable: false, datafield: ‘id’, width: 100 },{ text: ‘ Certificate Name’, datafield: ‘name’, width: 180 }
]
});
});waiting for solutions..
Regards…You can take a look at this sample: createremoveupdatedata.htm. It shows how to add, delete or update a Grid row.
Best wishes,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThans Peter…
You are owsum…u know me doing work on my final year project…
Jquery is intresting 🙂thanks onceagain..
Peter I need help…
now i can update data using php in jquery but i m not able to delete row from data grid…
thats php script$row[‘name’],
‘id’ => $row[‘id’]);
}echo json_encode($certificate);
}
?>and thats jquery code
$(document).ready(function () {
// prepare the data
var data = {};
var theme = ‘classic’;var source =
{
datatype: “json”,
datafields: [
{ name: ‘name’},
{ name: ‘id’}
],
id: ‘id’,
url: ‘data_qualification.php’,
updaterow: function (rowid, rowdata, commit) {
// synchronize with the server – send update command
var data = “update=true&name=” + rowdata.name;// + “&LastName=” + rowdata.LastName + “&Title=” + rowdata.Title;
/// data = data + “&Address=” + rowdata.Address + “&City=” + rowdata.City + “&Country=” + rowdata.Country + “&Notes=””;
data = data + “&id=” + rowdata.id;$.ajax({
dataType: ‘json’,
url: ‘data_qualification.php’,
data: data,
success: function (data, status, xhr) {
// update command is executed.
commit(true);
},//for delete row
deleterow: function (rowid, commit) {data = data + “&id=” + rowdata.id;
// synchronize with the server – send delete command
// call commit with parameter true if the synchronization with the server is successful
//and with parameter false if the synchronization failed.commit(true);
}
});
}
};var dataAdapter = new $.jqx.dataAdapter(source);
// initialize jqxGrid
$(“#jqxgrid”).jqxGrid(
{
width: 280,
height: 350,
selectionmode: ‘singlecell’,
source: dataAdapter,
theme: theme,
editable: true,
columns: [
{ text: ‘ID’, editable: false, datafield: ‘id’, width: 100 },{ text: ‘ Certificate Name’, datafield: ‘name’, width: 180 }
]
});
});// delete row.
$(“#deleterowbutton”).bind(‘click’, function () {
var selectedrowindex = $(“#jqxgrid”).jqxGrid(‘getselectedrowindex’);
var rowscount = $(“#jqxgrid”).jqxGrid(‘getdatainformation’).rowscount;
if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
var id = $("#jqxgrid").jqxGrid('getrowid', selectedrowindex);
var commit = $("#jqxgrid").jqxGrid('deleterow', id);
}
});i know there is some mistake…
waiting for answer..
REgards…
Farhad -
AuthorPosts
You must be logged in to reply to this topic.