Hello Ken,
Thank you for the feedback and glad to hear that it works as expected
Kind Regards,
Will
Guriddo Support Team
Hello Ken,
I think you missed my first post that when once created the pivot grid does not make any request to the php file.
I will explain it in detail.
In your case, when you include for the first time the file leaderboard.php in the index file it creates the pivot definitions and the grid is constructed without data. After it is created it send request ONLY ONCE to get all the needed data.
When data comes to grid it is transformed and there are NO MORE REQUESTS to leaderboard.php file. The grid is now in local mode. This can be easy seen if you try to sort, do a paging and etc – no requests to the server.
Because of this in order to do search, local build should be done like in our demo. No PHP code – only JavaScript code.
Kind Regards,
Will
Guriddo Support Team
Hello,
As far as I understand you missed to bind a click to search button and use the function which we provide in our demo.
Include our function from the example in your index.php and bind a click as we do in our code. You will need just to configure the input data to meet your requirements.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
/** * Build custom search string from array of objects * @param {Array} rule_arr the array where the data and rules are * @param {String} group group logical operator of the fields * @returns {String} */ function buildCustomSearch( rule_arr, group ){ if(group === undefined) { group = "AND"; } var ruleGroup = ""; if(Array.isArray(rule_arr) && rule_arr.length) { ruleGroup = "{\"groupOp\":\"" + group + "\",\"rules\":["; var gi=0; $.each(rule_arr,function(i,n){ if (gi > 0) {ruleGroup += ",";} ruleGroup += "{\"field\":\"" + n.name + "\","; ruleGroup += "\"op\":\"" + n.oper + "\","; ruleGroup += "\"data\":\"" + n.val.replace(/\\/g,'\\\\').replace(/\"/g,'\\"') + "\"}"; gi++; }); ruleGroup += "]}"; } return ruleGroup; } var grid = $("#jqGrid"); // rplace with your id $("#do_search").on('click',function(){ var my_fld=[]; /* *opts : ['eq','ne', 'lt', 'le', 'gt', 'ge', 'nu', 'nn', 'in', 'ni','bw', 'bn', 'ew', 'en', 'cn', 'nc'], */ /* my_fld.push({ name: "OrderDate", val : $("#from_date").val(), oper:"ge" }); my_fld.push({ name: "OrderDate", val : $("#to_date").val(), oper:"le" }); */ // configure my_fld in a way above to meet your needs var rule = buildCustomSearch( my_fld, "AND"); grid.setGridParam({postData:{filters:rule}, search:true}).trigger("reloadGrid"); }); |
Regards,
Will
Guriddo Support Team
Hello Ken,
Please check this demo example
If you have questions or something is not clear, please let us know.
Kind Regards,
Will
Guriddo Support Team
Hello Ken,
Yes this is possible.
You need to know that after the pivot grid is build, it stay in local mode and no request to server is possible.
In order to achieve this it is needed to build the filters string manually and pass it to postData which should do the job.
In the next days we will post a example how to do this. We think it will be useful to have such method.
Kind Regards,
Will
Guriddo Support Team
Hello Kris,
First of all we apologize that for some reason we have missed this post.
You can do this using the addLocalData method with true parameter
1 2 |
var grid = $("#grid")[0]; var filtered_data = grid.addLocalData( true ); |
Kind Regards,
Will
Guriddo Support Team
Hello Ken,
Just do some test with your table.
I apologize really for that, that I miss some important setting in the script.
Our original script work like champ if you add only one important setting
1 2 3 |
... $grid->getLastInsert = true; ... |
This option enables getting the lastInserId from the table.
By default it is fale.
We have tested with this setting and it work.
Sorry again for my mistake on this setting.
Kind Regards,
Will
Guriddo Support Team
Hello Ken,
Thank you for the update.
Actually we use the PDO lastInserId
I’m very curious if this script will work:
Replace
1 2 3 |
$sql = "select LAST_INSERT_ID()"; $stmt = $conn->query($sql); $lastInsertID = $stmt->fetch(); |
with
1 2 3 |
.... $lastInsertID = $conn->lastInsertId(); ... |
where $conn is the connection object.
and disable the transactions before do the insert
1 2 3 |
... $grid2->trans= false; ... |
I think that maybe the problem was in the transaction set to true.
Regards,
Will
Guriddo Support Team
Hello Ken
Would be possible to send us the table definition of tblLandOwners?
I mean the create table script.
Thank you.
Kind Regards
Will
Guriddo Support Team
Hello Kris,
Thank you very much for the suggestions.
return_fld can be a function See here
About the select – we do not have tested it on select, but I will see what we can do and will replay ASAP.
Thank you again for the suggestion.
Kind Regards,
Will
Guriddo Support Team
Hello,
We have send you e-mail.
Kind Regards,
Will
Guriddo Support Team
Hello Ken,
Thank you very much to point us of this problem.
We have found it and fixed it. It will be available in the next release.
If this is a showstopper, please let us know we will send you the fix.
Kind Regards,
Will
Guriddo Support Team
Hello,
Yes, there is a way to get the last inserted id, but only when the insert is done.
At the moment to do what you want some trick should be applied.
One possible way is to disable automatic add and at certain point of the code and perform some other operations
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
$grid->setTable('main_table'); // set the primary(uniquie) key $grid->setPrimaryKeyId('OrderID'); if($grid->oper == 'add') { // obtain the data posted from the client $data = filter_input_array(INPUT_POST); // try to insert the data in the table if( $grid->insert($data) ) { $LastInsert = $grid->getLastInsertId(); if($LastInsert) { $grid->setTable('child_table'); $grid->setPrimaryKeyId('OtherKey'); $grid->serialKey = false; $grid->insert( array( "OtherKey"=>$LastInsert, .....) ); } } } $grid->add = false; |
Note setTable before if and $grid->add = false after the if.
You can do a lot variations using this approach.
In the upcoming release we will add a special word in which the last inserted id can be used in setAfterCrud (thank you for point us to add this feature)
Kind Regards
Will
Guriddo Support Team
Hello,
To overcome such problems you can set PDO to use lower case or upper case.
By example if you do :
1 2 3 4 |
// Connection to the server $conn = new PDO(DB_DSN."tinicum",DB_USER,DB_PASSWORD); // Set the case in which to return column_names. $conn->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
then no mater how you write your column names, but this depend on the needs and should be used with care.
Kind Regards,
Will
Guriddo Support Team
Hello,
It is not a bug. We just fix some not wanted behavior of the search property in colModel for this method
To continue use the search on all fields set searchAll option to true in the method.
1 |
... $("#jqGrid").jqGrid('filterInput', self.value, {searchAll: true}); ... |
We have fixed our code in the demo too.
We understand that this will maybe break other users and have revert the change back. This will be available in the upcoming 5.8.2 release.
Kind Regards,
Will
Guriddo Support Team
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top