Hello Christian,
There is a problem with ajax sync:false when used with jQuery, so the suggestion I have made will not work.
I can suggest you another approach.
The idea is simple
1. Determine at server that we are in add mode.
2. Check if the record exists
3. do the needt to insert if it not exists
4.disable the automatic add operation in grid.
This code can look like this (note that we do not try this):
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
.... if($grid->oper === 'add') { $data = jqGridUtils::Strip($_POST); // you have here $data['nom'] and etc // Check here with your SQL if the record exists // suppose this is variable $recordexists if( !$recordexists ) { $grid->insert( $data ); } else { $grid->errorMessage = "Record exists"; $grid->sendErrorHeader(); } } // disable automatic add $grid->add = false; |
Kind Regards
Will
Guriddo Support Team
Hello,
Thank you for the feedback. We don’t try this, so it is a good that you post this for the other users.
Thank you.
Kind Regards
Will
Guriddo Support Team
Hello,
It depend where you want to put this logic – server side or client side.
I think that one possible solution is toy use a javascript formula parser something like this one
The idea is to bind a change event to this field using dataInit function and maybe it is better to use two fields one for the formula another for result, but I think it can be done with one field too.
Kind Regards,
Will
Guriddo Support Team
Hello,
Possible cuase is that in a case you do this, there are two ajax requests at the same time – your and the jqGrid one, which follow immediate after beforeSubmit
One possible resolution is the set is your request async : false in ajax settings
|
1 2 3 4 5 6 7 8 |
... $.ajax({ async : false, type: 'GET', dataType: 'text', data: {q1:nom, q2:prenom, q3:datenaissance}, url: 'g_nomprenomdate.php', ... |
Kind Regards,
Will
Guriddo Support Team
Hello,
Could you please let us know where and how you do this. If previously you use jqGrid JavaScript, then you can do this in PHP too – just let us know the JavaScript way.
Kind Regards,
Will
Guriddo Support Team
”
In inline edit you should add class “not-editable-row” in form edit you should add class “ui-state-disabled” for jQueryUI and “ui-disabled” when using bootstrap.
“
Guriddo Support Team
Hello,
Dear @cvneo it seems to me you do not have carefully read my posts. The solution is in some of my previous posts – you just need to read them.
Regards,
Will
Guriddo Support Team
Hello,
This behaviour is by default. I think you do something wrong. Records with ui-state-disabled are not selectable and not editable. Also the navigator button is disabled too if the next record is disabled.
See demo here
Kind Regards,
Will
Guriddo Support Team
Hello,
As I say in may previous post if you set desired rows with the class ui-state-disabled, the rows are not editable. The small function in this case is easy to be written.
|
1 2 3 |
function isEditable( rowid ) { return $("#rowid").hasClass("ui-state-disabled") ? true : false; } |
where the rowid is the id of the row.
Note that in this case the navigator buttons are disable autoamtically when you select the row with this class.
All you need is to set the desired class depending on your data
Regards
Will
Guriddo Support Team
Hello,
Sorry for the mistake.
If you use editor like NetBeans you can easy see the error.
a ” } ” is missing, Try this:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
onselrow = <<< ONSELROW function(rowid, selected) { if(rowid && rowid !== lastSelection) { $("#grid").jqGrid('restoreRow', lastSelection); $("#grid").jqGrid('editRow', rowid, { aftersavefunc : function() { setTimeout( function() { $("#grid").trigger("reloadGrid"); }, 10); } }); lastSelection = rowid; } } ONSELROW; |
Regards,
Will
Guriddo Support Team
Hello,
The syntax is correct, but you will need to put it in dblSelect Row
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
$grid->setGridOptions(array( "hoverrows"=>false, "footerrow"=>true, "userDataOnFooter"=>true )); $summaryrows = array("col1"=>array("col1"=>"SUM"), "col2"=>array("col2"=>"SUM")); onselrow = <<< ONSELROW function(rowid, selected) { if(rowid && rowid !== lastSelection) { $("#grid").jqGrid('restoreRow', lastSelection); $("#grid").jqGrid('editRow', rowid, { aftersavefunc : function() { setTimeout( function() { $("#grid").trigger("reloadGrid"); }, 10); }); lastSelection = rowid; } } ONSELROW; $grid->setGridEvent('ondblClickRow', $onselrow); $grid->renderGrid('#grid','#pager',true, $summaryrows, null, true,true); |
Regards,
Will
Guriddo Support Team
Hello,
Thank you very much for the information.
Kind Regards,
Will
Guriddo Support Team
Hello,
There are a lot of solutions. The easy stable way without to write a lot of code is to reload the grid (trigger(‘reloadGrid’) ) after the save is done.
For this purpose you can use the aftresavefunc in editRow method. Please look into the docs here
Kind Regards
Will
Guriddo Support Team
Hello,
Check your code again. See the errors setting at top of the php script
|
1 2 3 |
ini_set("display_errors",1); ... |
Maybe when update is in action some variable in your script are not set causing the update to stop.
My suggestion is to check if your variables from the sentence are set
|
1 2 3 4 5 6 |
... resultat=$sql->fetch(); $attestation_b= isset($resultat[‘attestation’]) ? $resultat[‘attestation’] : ""; $top_verse_b=isset($resultat[‘top_verse’]) ? $resultat[‘top_verse’] : ""; if ($top_verse_b == “O” && $attestation_b == 1) { ... |
Hope you get the point.
Kind Regards,
Will
Guriddo Support Team
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top