0

I am trying to send custom data to initialize my jqgrid row selection. I want to send the selected row id in the userdata section of the jqgrid ajax xml response.

Here is the xml snippet that I return:

<rows>
  <row> ...
  </row>
  <userdata>
    <selNodeId>64</selNodeId>
  </userdata>
</rows>  

When I ask for the the userData:

var userData = gridTree.getGridParam('userData')

Firebug shows a value of Object { null="64" }

jqgrid seems to parse the userdata xml and then throw away the 'selNodeId' identifier. Any ideas as to why the xml does not render an object with the proper 'selNodeId' property?

Bill Pfeiffer
  • 926
  • 8
  • 20

1 Answers1

1

Look at the documentation. You will find that correct format for the userdata should be

<userdata name="selNodeId">64</userdata>

I recommend you if it's possible to use JSON format instead of XML. In the case almost any data can be read. With respect of jsonReader which contain methods instead of properties and jsonmap defined as function you can read practically any JSON data. The format of XML data as jqGrid input have too many restrictions.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • This work just like the docs said. I looked at a version of the documentation on trirand's site searching on userdata and managed to miss it. Big thanks as this was the last link in making a rather largish feature work for me. – Bill Pfeiffer Sep 17 '11 at 19:48
  • @Bill Pfeiffer: You are welcome! One more time I can repeat that you should better use JSON instead of XML if it is only possible. – Oleg Sep 17 '11 at 20:05
  • Yeah I've now got refactoring XML responses to JSON on my to do list. – Bill Pfeiffer Sep 18 '11 at 10:34
  • @Bill Pfeiffer: By the way an example about the usage of `jsonmap` as function you can find [here](http://stackoverflow.com/questions/6902936/jquery-jqgrid-propery-with-dot-operator/6904980#6904980). – Oleg Sep 18 '11 at 10:40