0
i have set ,
editoptions: { aysnc: true, dataUrl: 'ControllerName/MethodName?__SessionKey=' + sessionkey + "&Id=" + Id, buildSelect: buildSelectFromJson, style: "width: calc(100% - 65px);",
                dataEvents: [
{
                                    type: 'change',
                                    fn: function (e) {}
}
]
}

in which buildSelectFromJson returns select list in html.

Now dataurl hits server for each row but my select list is same for all rows. so how can i restrict to a single hit and then use that select list for all other rows?

abcd1234
  • 5
  • 4

1 Answers1

0

I can suggest you two alternatives:

  1. the server code (responsible for the URL ControllerName/MethodName) can place HTTP caching header. For example Cache-Control: private, max-age=(time in seconds). It will force getting the data during specified time interval from the local web browser cache.
  2. You can make Ajax request to ControllerName/MethodName separately and set editoptions.value based on the response instead of usage editoptions.dataUrl (only if dataUrl is undefined the value will be used). See the answer for the code example of the possible implementation. By the way you can combine the call to ControllerName/MethodName with the main call for filling the grid. See the answer and this one.

By the way the property aysnc: true which you use in editoptions is unknown and it will be ignored.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • gr8...this works(2nd option)..but how do i add "--Select--" value with null id to the selectlist – abcd1234 Jun 15 '15 at 09:42
  • @GiteshKothavale: **Your code** build the `value`. Look at [the answer](http://stackoverflow.com/a/17410568/315935) which I reference in my answer. It shows the code like `$self.jqGrid("setColProp", "Product", { searchoptions: { value: ":All;" + newProductValues }, editoptions: { value: newProductValues } });`. So you need just set a little different values for `editoptions.value` and `searchoptions.value` – Oleg Jun 15 '15 at 09:49
  • setting searchoptions didn't worked.. but setting to editoptions: { value: ":Select;" + selectedOptions } worked..still its not allowing me to set "--Select--" – abcd1234 Jun 15 '15 at 10:27
  • one more problem is calling setSelectOptionValues on loadcomplete not working.. and calling it after jqgrid prepare end works sometimes (not always).. so where exactly we shud call setSelectOptionValues – abcd1234 Jun 15 '15 at 10:44
  • @abcd1234: I suggested you many variants of the implementation. `setSelectOptionValues` from [the answer](http://stackoverflow.com/a/21901410/315935) shows the simplest way which can be used for setting of `editoptions.value`. One places Ajax call directly *after* the grid is created. One will get response from the server typically *after* the user can start editing. So it will work. Other answers suggest more safe way where *the response from the server to fill the grid* contains additional information required for `editoptions.value` and `searchoptions.value`. One uses `beforeProcessing`. – Oleg Jun 15 '15 at 11:08
  • @abcd1234: The second way with the usage of `setColProp` inside of `beforeProcessing` (see [the answer](http://stackoverflow.com/a/17410568/315935) and read the question of cause) is the most flexibly and it's what I would recommend you to do. – Oleg Jun 15 '15 at 11:11
  • thnx Oleg...already tried calling it in beforeProcessing.. but problem still exist. In your example u r refreshing filterToolbar but i my case no such toolbar exist. The problem is sometimes grid fetches all records before setColProp gets called else it works. – abcd1234 Jun 15 '15 at 12:39
  • @abcd1234: You are welcome! Sorry, but I don't understand what you mean. You wrote "The problem is sometimes grid fetches all records before setColProp gets called". **What is not working exactly now?** What you do now? The problem was **editing** of data, isn't so. I need to see the code to point you the place where you made something incorrect. By the way I wrote in my answer: that you need to "set `editoptions.value` based on the response instead of usage `editoptions.dataUrl` (only if `dataUrl` is undefined the value will be used)". Are you sure that no `dataUrl` exist in `colModel`? – Oleg Jun 15 '15 at 12:54
  • yes... i tried $.ajax instead of getJson and set async:false... finally solved..its working now. – abcd1234 Jun 15 '15 at 12:59
  • :m using this code on after row insert to keep entire grid in edit mode $('#' + GridId).jqGrid('editRow', rowid, true); This code works but it scrolls down to the last record. is there any other way to keep grid in edit form – abcd1234 Jun 16 '15 at 06:27