javascript - passing json object to view and displaying in slickgrid -


the other posts on topic have helped me not completely. retrieving data wcf service (included in mvc 4 project) this:

warehousecontroller.cs

warehouseinput objwi = new warehouseinput();      public actionresult index(warehouseinput value)     {                    objwi.count = 15;         objwi.offset = 0;         objwi.query = "";         objwi.sort = "id";         objwi.order = "asc";         objwi.id = 0;         objwi.rowid = 0;         service1 c = new service1();         c.getwarehouselist(objwi);         //var model = c.getservices();     update 1  ----->      return view(objwi);         //return getwarehouselist(objwi);   update 2  ----->     //return json(objwi, jsonrequestbehavior.allowget);     } 

i getting data in json object...

data fetched

index.cshtml edit:

  @model mvcapplication1.ws.datacontracts.warehouseinput   @{ viewbag.title = "index";  }   <h2>index</h2>  <script type="text/javascript"> alert('0'); $.ajax({     url: '@url.action("index")',         type: 'get',         cache: false,         success: function(resp) {             alert(resp);             if (resp.warehouseresults != null) {                 var objtemp = resp.warehouseresults;                              //var = resp.offset, = + resp.warehouseresults.length;                             //data.length = parseint(resp.total);                             //for (var = 0; < resp.warehouseresults.length; i++) {                             //    data[from + i] = resp.warehouseresults[i];                             //    data[from + i].index = + i;                             //}                             //$("#lblrows").html("<b>total: " + resp.total + "</b>");                             //ondataloaded.notify({ from: from, to: });                         }                         else {                             //i = indicators.pop();                             //if (i != null)                             //    i.fadeout();                             alert('error loading page');                         }             alert('1');         }     }); alert('1.5'); var values = @html.raw(json.encode(model.warehouseresults)); var data = [];  var grid; var validator; 

the problem control never goes cshtml. how pass json object view (ui)? how display in slickgrid using? edit: javascript code needs revised, first have control reach there.

you need return view, not json. have line commented out want:

return view(objwi.warehouseresults); 

you have line in cshtml file turns json, have commented out:

var values = @html.raw(json.encode(model.warehouseresults)); 

what don't understand why calling getwarehouselist in action method , in javascript?

calling services javascript great reloading data without having load page. trying that? you're calling on jquery.ready once when page loads. when load page can embed json in html viewmodel.

stylojack_10: "while may not answer, got answer in our discussion, hence marking answer."


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -