jQWidgets Forums
Forum Replies Created
-
Author
-
Still unable to configure this. Upon clicking this edit button, alert 1 is showing up but not alert 2. It’s as if the click method for the button is not completing and therefore not calling the updaterow function of the grid.
If I manually edit a grid cell, the updaterow function gets triggered but I need to trigger it with the button before any editing takes place.
// edit row. editButton.click(function (event) { alert("1"); var datarow = generaterow(); alert("2"); var selectedrowindex = $("#jqxgrid").jqxGrid('getselectedrowindex'); var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount; if (selectedrowindex >= 0 && selectedrowindex < rowscount) { var id = $("#jqxgrid").jqxGrid('getrowid', selectedrowindex); $("#jqxgrid").jqxGrid('updaterow', id, datarow); } });
Will verify this. Thanks a lot.
Maybe I can express this a simpler way: Is there a way to pass the selected row values as a GET request to a php page using the grid functions?
I’m trying to submit a GET request with the selectedrow values to update the row in the database. I named editrow for testing purposes but was using updaterow before.
So basically what I’m attempting is:
When a user selects a row and clicks on the Edit Selected button defined below
editButton.click(function (event) { var selectedrowindex = $("#jqxgrid").jqxGrid('getselectedrowindex'); var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount; if (selectedrowindex >= 0 && selectedrowindex < rowscount) { var id = $("#jqxgrid").jqxGrid('getrowid', selectedrowindex); $("#jqxgrid").jqxGrid('updaterow', id); } });
I want to use the updaterow function to submit a GET request with the row values to a php file to postback to the database.
updaterow: function (rowid, rowdata, commit) { // synchronize with the server - send update command var data = "update=true&class+id=" + rowdata.class_id + "&period_id=" + rowdata.period_id; data = data + "&faculty_id=" + rowdata.faculty_id + "&class_title=" + rowdata.class_title; data = data + "&class_time=" + rowdata.class_time + "&class_limit=" + rowdata.class_limit; $.ajax({ dataType: 'json', url: 'form_classs.php', cache: false, data: data, success: function (data, status, xhr) { // update command is executed. commit(true) }, error: function (jqXHR, textStatus, errorThrown) { // cancel changes. commit(false); } }); },
The updaterow function does not seem to be triggering at all. A similar, or should I say identical approach is in place in my setup for the deleterow function. Upon selecting a grid row and clicking on the Delete button (described below), the function deleterow is being triggered successfully.
deleteButton.click(function (event) { var selectedrowindex = $("#jqxgrid").jqxGrid('getselectedrowindex'); var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount; if (selectedrowindex >= 0 && selectedrowindex < rowscount) { var id = $("#jqxgrid").jqxGrid('getrowid', selectedrowindex); $("#jqxgrid").jqxGrid('deleterow', id); } });
Here is the delete function again:
deleterow: function (rowid, rowdata, commit) { // synchronize with the server - send delete command var data = "delete=true&" + $.param({ class_id: rowid }); $.ajax({ dataType: 'json', url: 'data_classes.php', cache: false, data: data, success: function (data, status, xhr) { // delete command is executed. commit(true) alert('Class Deleted Successfully.') }, error: function (jqXHR, textStatus, errorThrown) { // cancel changes. commit(false) alert('Oops. Something went wrong. (FC-DB-03): ' + errorThrown); } });
Thanks!
-
AuthorPosts