jquery - jqGrid - Dynamically adding Rows Via Json -


I dynamically try to add rows on my jqGrid dependent at the value put in a text box I am here. There is a method that receives Jason request from the server, but I'm having trouble adding actual data.

The jqGrid code is:

  function RenderGrid (grid) {$ ( "# queryGrid") jqGrid ({datatype :. grid. DataType, MTYPE: grid.RequestType, colNames: grid.ColumnNames, colModel: grid.ColumnModel, pager: $ ( '#pager'), ROWNUM: grid.MaxViewableRows, caption: "search", width: GridkWidth, RowList: grid.MaxViewableRowOptions, height: grid.Height, loadtext: "Please wait ...", viewrecords: grid. I URL because the alternative is not determined, as I mentioned earlier, the data come from somewhere else. However, " This is colModel :  
  {" name ":" id "," index ":" id "," hidden ":" true Incorrect, "width": 216, "resizable": true} "{{name}:" customer "," index ":" customer "," type-type ":" int 32 "," editable " False "," width ": 216," resizable ": true}, {" name ":" shortName "," index ":" sHORTNAME "," sorttype ":" string "," editable " "name": "CorrespondenceName", "index": "CorrespondenceName", "Sorttype": "string", "editable": false, "width": 216, "resizable": true}   

Here is the code that is JSON :

  function SearchGrid () {$ .ajax ({url: $ .url (" / MyController / MyAction "), Ty Please: "post", datatype: "json", data: {name: $ ('# name'). Val (), Field: $ ('# Fields'). Text (),}, success: applied datatagrid // more on this question later)}; }   

How does all this work right? I do not think this issue is with any code above. I here is the place where it becomes difficult, this is where I get the JasonOn object and when I try to add it to the grid.

<">" "Id": 1, "cell": [94, "damman", "an identity"]}], "total": 1}

This code :

  function ApplyDataToGrid (data) {$ ("# queryGrid") [attempts] to add data to the grid [ 0] KaddJSONData (K data, $ ( "# queryGrid") bDiv, 0)}   

or

  function Deedtaogreed (data) {$ ( "#CreatorGrid") [0] .addJSONData (data)}   

It does count and page number Apply the text count but it does not display the line which should add the ID and the three columns!

Any thoughts? This is driving me crazy! Thanks in advance, Damien

Since you are calling an MVC controller to capture JSN data, I You would suggest Oleg what I suggested to do-you can empty-load your jqGrid and then, when the user clicks on a button or changes some text in the text box, you can trigger the grid reload Are: myGrid.trigger ('reloadGrid', [{Page: 1}]

Your grid has changed Will bring the fields and send it with the request:

  postData: {Param1: function () {return $ ("# filter1"). Val ();}, Parama 2: function () {Return $ ("# filter2"). Val ();}},   

If you are using ASP.NET MVC2 or 3 and posting your data want your action appears something like:

  [http post] public Jesn results Sksesm () (Jason (Apakadeta, Jesnaraijest Bihivier. Deniget);}    

Comments