<p>I think you’re right, it’s not the new jqGrid, but a new version of MySQL (MariaDB actually) that is not working as before. I ended up creating two columns for each one that was of type date that I needed to accept nothing being entered and also displaying an empty field if ‘0000-00-00’ was in the database, but one hidden and editable and the other visible and not editable.</p>
1 2 3 4 5 6 7 8 9 |
$grid->SelectCommand = 'SELECT ... (IF(invoices.srlinvoicedate!=\'0000-00-00\', invoices.srlinvoicedate, \'\')) srlinvoicedatedisplay, (invoices.srlinvoicedate) srlinvoicedate, ... FROM invoices' $grid->setColProperty('srlinvoicedatedisplay', array("label"=>"Invoice<br>date", "width"=>"80", "fixed"=>true, "align"=>"center", "search"=>false, "editable"=>false)); $grid->setColProperty('srlinvoicedate', array("label"=>"Invoice<br>date", "hidden"=>true, "width"=>"80", "fixed"=>true, "align"=>"center", "formoptions"=>array("rowpos"=>4, "colpos"=>3, "label"=>"SRL - Invoice date"), "search"=>false, "editrules"=>array("edithidden"=>true))); |
<p> </p>
<p>Here’s a picture that shows the code better:</p><p>https://i.imgur.com/49j44Xy.png</p>
Thank you. It worked.
<p>Am I doing something wrong when posting? All the HTML tags show up.</p>
<p>Thank you for the answer. I have purchased a new license of SuitoPHP with subscription and have received the automated email with the download link for version 5.5.5. In your message you mentioned version 5.7. Is that not out yet, or in beta?</p>
Thank you. It worked!
Thread can be marked as SOLVED and closed.
Thank you very very very much!
It worked with the <style> in the <html> section.
Thank you for the code. It kind-of works, but not for the property I need. The class gets applied to the correct rows, but the style attribute I wanted to change is the background color, and it doesn’t apply.
Here is what Firefox’s Inspector shows:
https://i.imgur.com/cWxSetn.png
If I use ‘color’ instead of ‘background-color’, the text color does change, but I needed the background to change, not the text. I added !important but it didn’t help.
I think it gets overridden by that .ui.widget-content class. Is it possible to have the backgroud-color apply without modifying the jqGrid css?
Thank you.
At first it didn’t work but I dug deeper into the parameters and figured out what I was doing wrong.
Here’s my code, in case someone else is trying to do the same thing and finds this thread:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$grid->setPrimaryKeyId('someColumn'); $myScript=<<<BLABLA function(response, postdata, oper) { if(oper === 'edit') { var rowid = postdata.someColumn; } // // here I put the stuff I need to do // return [true,'']; } BLABLA; $grid->setNavEvent('edit', 'afterSubmit', $myScript); |
Thank you for the solution.
Thread can be closed.
I’m thinking there is a third option:
3. Instead of assigning a long statement to a variable in SQL, use those statements as the first SELECT elements and then reference them in the same SELECT. Those columns can be set as hidden and not editable.
I’m wondering which would be better from a performance point of view. The first solution would require PHP to query the SQL, which has some overhead. The third would have jqGrid handle the extra columns to be hidden.
I tried the code above and I think it’s missing something. When I double-click on a row the editing starts but there’s no way to end it (either by a save or by a cancel). The buttons for ‘save row’ and ‘cancel row editing’ do not become active, and pressing Enter does not do anything.
OK, you mean something like this?
1 2 3 4 5 6 7 8 |
$refresh = <<< REFRESH function refreshAfterEdit() { jQuery("#grid").jqGrid('editRow', aftersavefunc: function(){ jQuery("#grid").trigger("reloadGrid"); }); }; REFRESH; |
Do I need to use setNavEvent to run this function?
I’m sorry my javascript skills are zero 🙁
Here is the relevant code:
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 |
$grid->setGridOptions(array( "grouping"=>true, "groupingView"=>array( "groupSummary" => array(true) ) )); $grid->setColProperty('bvnet', array("editable"=>false, formatter"=>"js:formatBVnumber", "unformat"=>"js:unformat", "summaryType"=>"sum")); $custom = <<<CUSTOM function formatBVnumber(cellValue, options, rowObject) { // first we replace dot with comma var modifiedCellValue = cellValue.replace(".",","); // we then format the number with spaces as thousands separator (this column always has 2 decimal places) if ( modifiedCellValue.length >= 10 ) { modifiedCellValue = modifiedCellValue.slice(0,-9) + " " + modifiedCellValue.slice(-9,-6) + " " + modifiedCellValue.slice(-6); } else if ( modifiedCellValue.length >= 7 ) { modifiedCellValue = modifiedCellValue.slice(0,-6) + " " + modifiedCellValue.slice(-6); } // then we change the color of the font var cellHtml = "<span style='color:SteelBlue' originalValue='" + cellValue + "'>" + modifiedCellValue + "</span>"; return cellHtml; } function unformat(cellValue, options, cellObject) { return $(cellObject.html()).attr("originalValue"); } CUSTOM; $grid->setJSCode($custom); |
The cells in this column look as intended, but the sums are black and have the default formatting (no spaces as thousands separator and has dot as decimal separator).
I forgot to mention that the summary is not displayed correctly only when using:
1 2 3 4 5 6 |
$grid->setGridOptions(array( "grouping"=>true, "groupingView"=>array( "groupSummary" => array(true) ) )); |
If I don’t use grouping in setGridOptions, the summaries are formatted correctly if used like this:
1 2 3 4 |
$summaryrows = array( "somecolumn"=>array("somecolumn"=>"SUM") ); $grid->renderGrid('#grid','#pager',true, $summaryrows, null, true,true); |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top