Thanks, it worked.
I tried also to use a summary row, but the values there are not formatted according to the custom function I defined. Is there a way to have the numbers in the summary row shown with comma as decimal separator?
Aha, what I need to do is something like this?
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
$grid->setColProperty('hourlyrate', array("label"=>"Rate (&euro;)", "width"=>"40", "fixed"=>true, "align"=>"right", "formatter"=>"js:numFormat")); $custom = <<<CUSTOM function numFormat(cellvalue, options, rowObject){ return cellvalue.replace(".",","); } CUSTOM; $replacecomma = <<<REPLACECOMMA function replacecomma(){ what do I put here? } REPLACECOMMA; $grid->setNavEvent('edit', 'serializeEditData', $replacecomma); $grid->setNavEvent('add', 'serializeEditData', $replacecomma); $grid->setJSCode($custom); |
How do I create the function that changes just some columns?
Thank you guys, it worked based on your solution sent over email.
I’m posting here the relevant lines of code, so anyone faced with this issue and finding this thread can see the proper solution.
|
1 2 3 4 5 6 7 8 9 10 11 12 |
$balances=<<<BALANCES function() { jQuery("#balances").trigger("reloadGrid"); return [true,'']; } BALANCES; $grid->setNavEvent('edit', 'afterSubmit', $balances); $grid->setNavEvent('add', 'afterSubmit', $balances); $grid->setNavEvent('del', 'afterSubmit', $balances); |
Where can I send you the files?
As I explained above, my html file has this:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
<body> <?php echo "<div style=\"clear:left\">"; echo "<p style=\"font-size:12px;font-family:verdana,arial,sans-serif\"><b>Cash (RON)</b></p>"; include ("cashron-grid1.php"); echo "</div>"; echo "<div style=\"clear:left;margin-left:350px\">"; echo "<br><p style=\"margin-left:120px;font-size:12px;font-family:verdana,arial,sans-serif\"><b>Balances</b></p>"; include ("cashron-grid2.php"); echo "</div>"; ?> </body> |
And in cashron-grid1.php I have:
|
1 2 3 4 5 6 7 8 |
$balances=<<<BALANCES function() { jQuery("#balances").jqGrid('setGridParam',{postData:{cashronid:rowid}}); jQuery("#balances").trigger("reloadGrid"); } BALANCES; $grid->setGridEvent('afterSubmit', $balances); |
So I need to refresh the grid in cashron-grid2.php when I add/edit/delete in cashron-grid1.php, but the above event does not work.
Hmm…, how do I paste code here? I tried the “code” in square brackets tags but they don’t work.
I mentioned the “detail” example in the demo because I also have a page with 2 grids, but in my case the second grid does not need any rowid from the first grid.
I just need to refresh the second grid every time I add (or edit, delete) a row in the first grid.
Here is the code that I use:
The <body> section of the html file (actually it’s a .php file):
[code]
<body>
<?php
echo "<div>";
echo "<p style=\"font-size:12px;font-family:verdana,arial,sans-serif\"><b>Cash (RON)</b></p>";
include ("cashron-grid1.php");
echo "</div>";
echo "<div>";
echo "<br><p style=\"margin-left:120px;font-size:12px;font-family:verdana,arial,sans-serif\"><b>Balances</b></p>";
include ("cashron-grid2.php");
echo "</div>";
?>
</body>
[/code]
In cashron-grid1.php I have:
[code]
$balances=<<<BALANCES
function()
{
jQuery("#balances").jqGrid(‘setGridParam’,{postData:{cashronid:rowid}});
jQuery("#balances").trigger("reloadGrid");
}
BALANCES;
$grid->setGridEvent(‘afterSubmit’, $balances);
[/code]
The purpose is to refresh the grid in cashron-grid2.php every time I add/edit/delete in cashron-grid1.php.
Grid2 does not need a rowid from the changed row in grid1. It just calculates some totals, but with different WHERE statements in the SQL query.
I use formedit.
I want to achieve something similar to your demo at:
http://www.guriddo.net/demo/demos/jqgrid/
in “Selection” -> “Master detail on select”.
There the “detail” grid gets refreshed every time a row is selected in the grid above.
What I need is the same refresh of the “detail” grid (in my case it’s called “balances”), only I need it to happen when a row is added or edited or deleted in the first grid.
The event “afterSubmit” does not seem to work for me. If I replace it with “onRowSelect”, it works on selects, so all the other code is correct, it’s just the event that needs to be changed, and I don’t know which is the correct one.
Thanks, it worked!
Sorry for not seeing the related information in that thread.
So, the code you posted in that thread is for jqGrid JS:
|
1 2 3 4 5 |
$("#grid").jqGrid({ ... storeNavOptions : true, ... }); |
For PHP it is like this?
$grid->storeNavOptions = true;
Does it matter the position in the code for this line? Can I put it right after:
|
1 2 3 4 5 6 7 8 9 10 |
$jscode = <<<CODE $("#savestate").click(function(){ $.jgrid.saveState("grid"); }); $("#loadstate").click(function(){ $.jgrid.loadState("grid"); }); CODE; $grid->setJSCode($jscode); |
Thanks, it worked!
Also, can you tell me if there’s an easy way to make the grey background (behind the add and edit panels) only cover the grid that is being added or edited? Right now it covers the entire page, including my second grid. (should I create a different thread for this?)
I am displaying a second grid below the main one. The second grid show entries that were added that day and I need to use an event in the main grid to trigger a refresh of the second grid.
So in the main grid I tried to use the following:
$refreshtoday = <<<ENDTODAY
function()
{
jQuery(“#detail”).trigger(“reloadGrid”);
}
ENDTODAY;
$grid->setGridEvent(‘afterInsertRow’, $refreshtoday);
But the above triggers the refresh for every row the main grid displays (so if I have 20 rows per page, the event triggers 20 times). I wanted to trigger only when a new row is added (via the add panel).
Thank you for the info.
For anyone having the same problem, here is how to do it:
$grid->setDatepicker(‘mycolumn’, array(“firstDay”=>”1”));
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top