0

I am use jqgrid. I want to add record inline navigation Now I want add select Box in Rows Field. how it possible? I am get Data from Database using Ajax and I want to add these data in Select Box. How its Possible? Please Help My Ajax Code

$.ajax({
 url : "getAllWards.html",
 data : "&time=" + new Date().getTime(),
 type : 'GET',
 dataType : 'JSON',
 success : function(data) {}
});

my JqGrid Code

jQuery("#room").jqGrid(
{
 mtype : 'GET',
 url : "listAllRooms.html",
 colModel : [ .....,
 ,{
name : 'wardType',
index : 'wardType',
width : 150,
edittype: "select",
editrules: { required: true },
editoptions: { size: 71},
editable:true,
}],
Ashish Mehta
  • 7,226
  • 4
  • 25
  • 52
  • @Oleg please help How add Dynamic Data in select box – Ashish Mehta Oct 26 '12 at 06:52
  • @oleg Above problem is solve jQuery("#room").jqGrid('setColProp','wardType', { editoptions: { value: wardTypes} }); where wardTypes is variable get from the database using Ajax now i want to add set ward id to its Optionvalue and wardType to option.SO how its? – Ashish Mehta Oct 26 '12 at 07:20
  • I have seen the second comment only now after posting the answer. So 1) if you want send me notification you should write comment with "@Oleg" in some my *previous answer*. If you post new question "@Oleg" can't be resolved. See [here](http://stackoverflow.com/users?tab=reputation&filter=all&search=oleg) for different users with the same name. – Oleg Oct 26 '12 at 07:44
  • It seems to me that you should better use `dataUrl` with probably `buildSelect` for formatting. See [the answer](http://stackoverflow.com/a/4102155/315935) and [here](http://stackoverflow.com/a/7877286/315935). – Oleg Oct 26 '12 at 07:50

1 Answers1

1

If you want use edittype: "select" you should specify value or dataUrl property of editoptions.

The demo provide as example.

UPDATED: It seems to me that you should better use dataUrl with probably buildSelect for formatting. See the answer and another one.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • in dataUrl code Url = ? is My Ajax Url and GetDestinationList= ? – Ashish Mehta Oct 26 '12 at 08:17
  • @AshuMehta: Sorry, but I don't understand what you mean. If you use ASP.NET you should just read [the answer](http://stackoverflow.com/a/7877286/315935) or download the demo project which I provide. – Oleg Oct 26 '12 at 08:25
  • I have wardId and wardName two field and these two field to set in – Ashish Mehta Oct 26 '12 at 09:06
  • by Using Ajax I get Id and type – Ashish Mehta Oct 26 '12 at 09:12
  • now these 'id' set in jqgrid select box value and 'Type' set in – Ashish Mehta Oct 26 '12 at 09:13
  • i Want like these jQuery("#room").jqGrid('setColProp','Ward_Type', { editoptions: {value:'WardId:wardTypes'}); but it gives Error – Ashish Mehta Oct 26 '12 at 09:18
  • @AshuMehta: You can return from the server (from the URL specified by `dataURL`) the HTML fragment `...`. Alternatively you can build the HTML fragment inside of `buildSelect` from the data in another format. For example you can return from `dataUrl` JSON `[{"id":"123","name":"Type 1"},{"id":"456","name":"Type 2"}]` and convert the object in above HTML fragment inside of `buildSelect`. – Oleg Oct 26 '12 at 09:23
  • @AshuMehta: I personally prefer to post to jqGrid only the texts of ` – Oleg Oct 26 '12 at 09:26
  • By using Json I GOt Data Like {"rows":[{"id":"1","cell":["1","General",null]},{"id":"2","cell":["2","AC","AC"]},{"id":"3","cell":["3","Special-S","special-s"]},{"id":"4","cell":["4","OT","ot"]},{"id":"5","cell":["5","NICU","nicu"]}]} And How to use BuildSelect And HTML fragment – Ashish Mehta Oct 26 '12 at 09:28
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/18622/discussion-between-ashumehta-and-oleg) – Ashish Mehta Oct 26 '12 at 09:31