jQuery UI Widgets › Forums › Grid › jqxGrid Context Menu delete records on DB server
This topic contains 5 replies, has 2 voices, and was last updated by gusty 11 years, 5 months ago.
-
Author
-
Hello,
I tried to use the jqxGrid Context Menu in my application but this model do not delete records on the DB server ( MySQL in my case )
I suppose I have to define the function:deleterow: function (rowid, commit) {
// 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);
}
but I don’t know how to do it.Thanks in advance.
Hello gusty,
You can find the answer in the tutorial CRUD with jqxGrid, ASP.NET MVC3 and SQL.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Thank you for your answer, but it’s not what I need. I do not use ASP.NET, I use PHP.
More precisely, I want the sequence code for the function: deleterow: function (rowid, commit) from the “context menu grid ” example and the coresponding code in the associated .php file that deletes the selected row in the grid and in the MySQL database.
In other words, I want the example “context menu grid” not with an array data source ( as it’s posted on the site ).
Many thanks in advance.
Hi gusty,
In that case, the tutorial Build CRUD Web App with jqxGrid using PHP and MySQL may be helpful to you. There you can find the deleterow callback function.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hy Dimitar,
Before posting this request, I already tried what you recommended in your answer. The problem is that it doesn’t work or I don’t know how to adapt it for “Context Menu Grid” model. That’s why I asked the code sequence for deleterow function and the associated code in the .php file.
If you can help me with this, will be super ok.Kind regards.
My .html file contains:
deleterow: function (rowid, commit) {
// synchronize with the server – send delete command
var data = “delete=true&” + $.param({ id: rowid });
$.ajax({
dataType: ‘json’,
url: ‘context.php’,
cache: false,
data: data,
success: function (data, status, xhr) {
// delete command is executed.
commit(true);
},
error: function (jqXHR, textStatus, errorThrown) {
commit(false);
}
});
commit(true);
}and .php file contains:
if (isset($_GET[‘delete’]))
{
// DELETE COMMAND
$delete_query = “DELETE FROM `employees` WHERE `EmployeeID`='”.$_GET[‘EmployeeID’].”‘”;
$result = mysql_query($delete_query) or die(“SQL Error 1: ” . mysql_error());
echo $result;
$sql = “SELECT FOUND_ROWS() AS `found_rows`;”;
$rows = mysql_query($sql);
$rows = mysql_fetch_assoc($rows);
$new_total_rows = $rows[‘found_rows’];
$query = “SELECT * FROM employees “.$where.” LIMIT $start, $pagesize”;
$total_rows = $new_total_rows;
}The problem is that the branch: if (isset($_GET[‘delete’]))
it’s not executed and in this case the selected row in the table it’s not deleted but in the displayed grid it’s deleted – the deleterow function it’s executed. -
AuthorPosts
You must be logged in to reply to this topic.