0

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

  • What is your current problem? Is `dataUrl` will be not called? Do you need to send `param1` which is different in every rows? Do you have some problem with caching (for example `dataUrl` will be loaded once and will be not retrieved every time)? Which fork of jqGrid ([free jqGrid](https://github.com/free-jqgrid/jqGrid), [Guriddo jqGrid JS](http://guriddo.net/?page_id=103334) or old jqGrid in version <=4.7) and in which version you use? Which editing mode you use (form editing, inline editing or cell editing)? – Oleg Aug 25 '15 at 07:09
  • Thanks Oleg. My problem is that the values are cached. I want to force to update the values by dataUrl when editGridRow. I am using the form editing. – user2430607 Aug 25 '15 at 07:19
  • **Which version of jqGrid you use?** Where is the code where you start `editGridRow`? Which options of `editGridRow` you use? Which web browser you used for the tests? Do you set and caching option (`Cache-Control`) in HTTP header of the response of `dataUrl` (see your server code). You should click on "edit" link below of your question and modify/append the text with additional information. – Oleg Aug 25 '15 at 07:27
  • I am using jqGrid 3.6. See above for the editGridRow. I am using chrome and I did not set the caching option of the HTTP header of the response of dataUrl, please check the server code as well. – user2430607 Aug 25 '15 at 07:43
  • You should update jqGrid to more recent version which is 7 years old. It's the time of IE4 and starting IE5. Do you still use such old versions of web browsers? Using steam car now is not good. I would recommend you to update to [free jqGrid](https://github.com/free-jqgrid/jqGrid) 4.9.2. You can try it just by replacing (at least temporary) of URL to jqGrid files. See [the wiki article](https://github.com/free-jqgrid/jqGrid/wiki/Access-free-jqGrid-from-different-CDNs). – Oleg Aug 25 '15 at 07:53

1 Answers1

1

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.

Oleg
  • 220,925
  • 34
  • 403
  • 798