When using jqgrid, is there anyway to have recreateForm: true but also cache dataUrl?

前端 未结 1 452
耶瑟儿~
耶瑟儿~ 2020-12-20 07:31

I have the following columns using jqGrid (simplified)

  { name: \"PMOPerson\", index: \"PMOPerson\", width: 250, editable: true, edittype: \"select\", edito         


        
1条回答
  •  被撕碎了的回忆
    2020-12-20 08:01

    I answered on very close questions here and here. In other words you can either use caching options of HTTP header or to use editoptions.value instead of editoptions.dataUrl.

    I described in the answer and this two previous one (this and this) how one can set editoptions.value dynamically inside of beforeProcessing callback. One need extend the responses from the server used to fill the grid with additional information (with the data like the data returned from editoptions.dataUrl). In my opinion it implements the best compromis between caching of editoptions.dataUrl data and refreshing of the data by reloading of the grid. One can still hold cached editoptions.dataUrl data on the server side.

    Alternatively one can use more simple way where one makes manual Ajax request to editoptions.dataUrl once after creating of the grid and one can set editoptions.value inside of success (done) callback of the Ajax request. The code will be about the following

    // create grid
    $("#grid").jqGrid({
        colModel: [
            { name: "PMOPerson" },
            ...
        ],
        ...
    });
    
    // make separate asynchronous Ajax request to the server and set 
    //  edittype: "select", editoptions: { value: ... }
    setSelectOptionValues("/Person/GetSelectData", $("#grid"), "PMOPerson");
    

    The code of setSelectOptionValues depends on the format of JSON data which you use to communicate with URL like "/Person/GetSelectData". For example if the server returns just array of strings wich should be the text and the value of options of the

    提交评论

提交回复
热议问题