jqgridjqgrid-php

Retrieve the column values of jqgrid dynamically


Here is my code of jqGrid.

$("#grid").jqGrid({
                        url:$url,
                        editurl:"serivce.php",
                        datatype: "json" ,
                        mtype:"post",
                        colNames:["test"],                             
                        colModel:[
                            {name:"test",index:"test", width:150,align:"center", editable:true, 
                                edittype:"select", editoptions:{size:1, dataUrl:"../someurl.php?param1=parm } 
                            },
                        ],
                        rowNum:10,
                        rowList:[10,20,30],
                        add: {
                            top:30,
                            left:20
                        },
                        edit:{
                            top:30,
                            left:20
                        },   
                        jqModal: true,
                        pager: "#page",
                        sortname: "ID",
                        viewrecords: true,
                        sortorder: "ASC",                            
                        shrinkToFit: true,
                        height: "auto"
                    });  ';



$("#grid").setGridParam({ondblClickRow: function(rowid) {
                                var rowData = jQuery("#grid").getRowData(rowid);                                     
                                    jQuery(this).jqGrid("editGridRow", rowid,
                                    {   closeAfterEdit:true,
                                         beforeShowForm: function(form){
                                            // force the data value retrieve here 
                                         },
                                        afterSubmit:function() { $("#grid").jqGrid("setGridParam", {datatype: "json"});
                                                                 return true;
                                                               }       
                                    });
                            } // end of ondblClickRow});
                          }); ' ;

The server php code of the dataUrl :

$values = getWorkingValues($param);
echo '<select>';
foreach($values as $value){
    echo "<option value='" . $value . "'>" .$value . "</option>"; 
}
echo "</select>";

How to force the retrieve of the values in "test" column?
for example, every time the grid is open for editing?
The version I am using is jqGrid 3.6. Thanks


Solution

  • You can try to add recreateForm: true option to the options of editGridRow (near closeAfterEdit:true).

    I would strictly recommend you to update jqGrid. jqGrid 3.6 is 7 years old which is really very much in web development. One had at the time IE4 and IE5 was just published. No from the web browsers are supported now. So you try to use the version from the stone Age of web development. You will be not able to find even the documentation about the old version. I would recommend you to update to free jqGrid 4.9.2 which you can download from GitHub, NuGet, npm or just use directly from CDN (see the wiki article). By the way the meaning of recreateForm option is different in different versions of jqGrid. If you would use free jqGrid then you will don't need to use recreateForm: true option to solve the problem.

    A would recommend you additionally to set Cache-Control: private, max-age=0 HTTP header in the server response of dataUrl. In the way you will be sure that the previous request will be not cached on the client side and the web browser will make the corresponding Ajax request every time.