I am not sure if this is specifically related to stored procedure, but at this point it the only thing I can think of. I am still pretty green when it comes to Kendo, so perhaps I am doing something silly.
The scenario is pretty simple.
I have a stored procedure that retrieves product information. This result set will never be that big, so I pass the data in the model to load the grid initially.
Once loaded, I want t use Ajax to manage the grid. I add a read method called "Get" which should return a Json result converted into the form of the original request using the .ToDataSourceResult . The Get method calls the same stored procedure that my Index method did to retrieve data.
The grid initially loads fine, and when I click on a page number the "Get" method is fired as expected
What happens next is that the grid disappears and is replaced with a text represenation of the Json results from the Get method.
When I trace the code I also note that the request object in the Get method has a count of 0 which makes me suspcious.
Here is my code:
CONTROLLER:
public ActionResult Index()
{
var results = db.GetLanaugeProductInfo("MX", 11660).ToList();
return View(results);
}
public JsonResult Get([DataSourceRequest]DataSourceRequest request)
{
var results = db.GetLanaugeProductInfo("MX", 11660).ToList();
return this.Json(results.ToDataSourceResult(request),JsonRequestBehavior.AllowGet);
}
VIEW
@model IEnumerable<NewGlobalProductCatalogue.Models.usp_IPCGetProductInfo_Result>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@{string lang = "EN";}
@(Html.Kendo().Grid(Model)
.Name("ProductInfo_" + lang)
.Columns(columns =>
{
columns.Bound(c => c.ColumnName);
columns.Bound(c => c.FieldName);
columns.Bound(c => c.MasterDataValue);
columns.Command(command => { command.Edit(); });
})
.DataSource(d => d
. Ajax()
.Read(r => r.Action("Get", "Product"))
.Model(m =>
{
m.Id(p => p.FieldID);
m.Field(p => p.ColumnName).Editable(false);
m.Field(p => p.FieldName).Editable(false);
m.Field(p => p.MasterDataValue).Editable(true);
})
.Update(u => u.Action("Update", "Product"))
)
.Pageable()
.Editable(e => e.Mode(GridEditMode.InLine))
)
I've attached a couple of screen shots. The first shows the grid after it is first loaded. The second shows the raw data I get back when I click on page 2.
Hopefully someone will be able to tell me what is going on here, and point me in the right direction.
Many thanks.
The scenario is pretty simple.
I have a stored procedure that retrieves product information. This result set will never be that big, so I pass the data in the model to load the grid initially.
Once loaded, I want t use Ajax to manage the grid. I add a read method called "Get" which should return a Json result converted into the form of the original request using the .ToDataSourceResult . The Get method calls the same stored procedure that my Index method did to retrieve data.
The grid initially loads fine, and when I click on a page number the "Get" method is fired as expected
What happens next is that the grid disappears and is replaced with a text represenation of the Json results from the Get method.
When I trace the code I also note that the request object in the Get method has a count of 0 which makes me suspcious.
Here is my code:
CONTROLLER:
public ActionResult Index()
{
var results = db.GetLanaugeProductInfo("MX", 11660).ToList();
return View(results);
}
public JsonResult Get([DataSourceRequest]DataSourceRequest request)
{
var results = db.GetLanaugeProductInfo("MX", 11660).ToList();
return this.Json(results.ToDataSourceResult(request),JsonRequestBehavior.AllowGet);
}
VIEW
@model IEnumerable<NewGlobalProductCatalogue.Models.usp_IPCGetProductInfo_Result>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@{string lang = "EN";}
@(Html.Kendo().Grid(Model)
.Name("ProductInfo_" + lang)
.Columns(columns =>
{
columns.Bound(c => c.ColumnName);
columns.Bound(c => c.FieldName);
columns.Bound(c => c.MasterDataValue);
columns.Command(command => { command.Edit(); });
})
.DataSource(d => d
. Ajax()
.Read(r => r.Action("Get", "Product"))
.Model(m =>
{
m.Id(p => p.FieldID);
m.Field(p => p.ColumnName).Editable(false);
m.Field(p => p.FieldName).Editable(false);
m.Field(p => p.MasterDataValue).Editable(true);
})
.Update(u => u.Action("Update", "Product"))
)
.Pageable()
.Editable(e => e.Mode(GridEditMode.InLine))
)
I've attached a couple of screen shots. The first shows the grid after it is first loaded. The second shows the raw data I get back when I click on page 2.
Hopefully someone will be able to tell me what is going on here, and point me in the right direction.
Many thanks.