This seems to be an ongoing question with no clear and concise explanation. I'm facing this same problem going on 2 days trying different things and suggestions to no apparent solution.
All I need to do and apparently the OP as well, is to send a parameter from the datagrid call. I need this parameter in order to have one php file with multiple functions, instead of one php file for every datagrid load, update, delete...etc.
I really want to use easyui and want to implement it in my project, but if I can't get this to work, it is a deal breaker for me and would have to move on to something else.
My datagrid looks like this.
<table id="tt" title="Articulos" class="easyui-datagrid" style="width:700px;height:300px"
iconCls="icon-search"
toolbar="#toolbar, #tb" pagination="true"
rownumbers="true" fitColumns="true" singleSelect="true"
data-options="method:'post',url:'items.php',queryParams:{action:'items'}">
Have also tried this
<table id="tt" title="Articulos" class="easyui-datagrid" style="width:700px;height:300px"
url="items.php?action=items'
iconCls="icon-search"
toolbar="#toolbar, #tb" pagination="true"
rownumbers="true" fitColumns="true" singleSelect="true"
data-options="method:'post',url:'items.php',queryParams:{action:'items'}">
And a couple of other permutations.
In my php file items.php I am checking if the action parameter is being passed and check if its value is items, if so, then fire off a function within that php file that returns a json result which should be used to load the data grid.
<?php
include 'conn.php';
f (isset($_POST["action"]) && !empty($_POST["action"])) { //Checks if action value exists
$action = $_POST["action"];
echo $action;
switch($action) { //Switch case for value of action
case "items": get_all_items(); break;
}
}
function get_all_items(){
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$type_id = isset($_POST['type_id']) ? mysql_real_escape_string($_POST['type_id']) : '';
$brand_id = isset($_POST['brand_id']) ? mysql_real_escape_string($_POST['brand_id']) : '';
$color_id = isset($_POST['color_id']) ? mysql_real_escape_string($_POST['color_id']) : '';
$upc = isset($_POST['upc']) ? mysql_real_escape_string($_POST['upc']) : '';
$size_id = isset($_POST['size_id']) ? mysql_real_escape_string($_POST['size_id']) : '';
$gender_id = isset($_POST['gender_id']) ? mysql_real_escape_string($_POST['gender_id']) : '';
$material = isset($_POST['material']) ? mysql_real_escape_string($_POST['material']) : '';
$offset = ($page-1)*$rows;
$result = array();
$rs = mysql_query("select count(*) from items");
$row = mysql_fetch_row($rs);
$result["total"] = $row[0];
$rs = mysql_query("select * from items limit $offset,$rows");
$items = array();
while($row = mysql_fetch_object($rs)){
array_push($items, $row);
}
$result["rows"] = $items;
echo json_encode($result);
}
?>
I really hope someone can let me know what I'm doing wrong here, because I can't figure out what I'm missing.
Sorry to the OP, didn't want to hijack your post, but seems like we are facing the same issue and didn't want to open a duplicate thread.
Thank you.