asp.net - Teleric Grid returns 500 Error -
hello working on returning partial view div using ajax in asp.net mvc3. view contains teleric grid
this view code
<input type="text" style="width: 320px;border: 1px solid rgb(177, 177, 177);" id="orderidtoimport" onkeydown = "return (event.keycode!=13);" /> <input type="button" class="t-button" value="import" name="add" id="importproducts" onclick="importproductsfromorder();" /> <div id="importedproducts"> </div> <script type="text/javascript"> function importproductsfromorder() { var orderid = $('#orderidtoimport').attr('value'); if(orderid=="") { alert('please specify orderid'); } $.ajax({ cache:true, type: "post", url: "@(url.action("importproducts", "order"))", data: "orderid=" + orderid , success: function (data) { $("#importedproducts").html(data); return false; }, error:function (xhr, ajaxoptions, thrownerror){ //alert('failed subscribe.'); }, complete: function() { } }); // end ajax code return false; } </script>
following controller actions
public actionresult importproducts(int orderid) { var model = new importedproductsmodel(); model.id = orderid; var order = _orderservice.getorderbyid(model.id); return partialview("importproducts", model); } [gridaction(enablecustombinding = true)] public actionresult importedproductsingrid(gridcommand command, importedproductsmodel model) { var order = _orderservice.getorderbyid(model.id); var orderproductvariants = order.orderproductvariants.where(o => !o.deleted); var gridmodel = new gridmodel<importedproductsmodel> { data = orderproductvariants.select(x => { return new importedproductsmodel() { id = x.id, name = x.productvariant.product.name, quantity = x.quantity, unitpriceexcltax = x.unitpriceexcltax, taxrate = x.unitpriceexcltax / (x.unitpriceexcltax - x.unitpriceexcltax), unitpriceincltax = x.unitpriceincltax, mrp = x.oldprice, unitcost = x.unitcost }; }), total = orderproductvariants.count() }; return new jsonresult { data = gridmodel }; // return partialview("searchproduct", model.productsearchresult); }
my partial view follows
@model importedproductsmodel @using telerik.web.mvc.ui @using (html.beginform()) { <p> </p> <table class="admincontent"> <tr> <td> @(html.telerik().grid<importedproductsmodel>() .name("importedproducts-grid") .clientevents(events => events.ondatabinding("ondatabinding")) .columns(columns => { columns.bound(x => x.id); columns.bound(x => x.name); columns.bound(x => x.quantity); columns.bound(x => x.unitpriceexcltax); columns.bound(x => x.taxrate); columns.bound(x => x.unitpriceincltax); columns.bound(x => x.mrp); columns.bound(x => x.unitcost); }) .pageable(settings => settings.pagesize(40).position(gridpagerposition.both)) .databinding(databinding => databinding.ajax().select("importedproductsingrid", "order", model)) .enablecustombinding(true)) </td> </tr> </table> <script type="text/javascript"> function ondatabinding(e) { //alert('hi'); } </script> }
i returing requested url returned 500 error
any solutions?
try... ...
.databinding(databinding => databinding.ajax().select("importproducts", "order", model))
....
[gridaction(enablecustombinding = true)] public actionresult importproducts(gridcommand command, importedproductsmodel model) { .... return view(new gridmodel(gridmodel)); }
Comments
Post a Comment