This is a migrated thread and some comments may be shown as answers.

kendo grid in kendo tabs using partial view

1 Answer 187 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 25 Apr 2013, 05:28 AM
For some reason i can get second tab (Product Details) to bind record in the grids although the GetAllProductList return records. Please advise, thank you

index.cshtml

@(Html.Kendo().TabStrip()
.Name("tabstrip")
.Items(items =>
{
items.Add().Text("Search")
.LoadContentFrom("Index", "ProductDetails")
.Selected(true);



items.Add().Text("Product Details")
.LoadContentFrom("_Product", "ProductDetails")



})
)

_Product.chtml (Partial page)

@(Html.Kendo().Grid<HH.PrductModel>()

.Name("Product")
.HtmlAttributes(new { @Style = "align:center; font-size:10px; width:950px" })
.Columns(columns =>
{

columns.Bound(p => p.ProductId).Width(95);
columns.Bound(p => p.Name).Width(120);


})

.ToolBar(toolbar => toolbar.Create())
.Sortable()
//.Pageable()
.Pageable(paging => paging
.Input(false)
.Numeric(true)

.PreviousNext(true)
.PageSizes(new int[] { 5, 10, 25, 50 })
.Refresh(false)

)
.Selectable()
.Scrollable()
.ColumnMenu(c => c.Columns(false))
.DataSource(dataSource => dataSource

.Ajax()//bind with Ajax instead server bind
.PageSize(10)
.ServerOperation(true)
.Model(model =>
{
model.Id(p => p.ProductId);

})
.Sort(sort => sort
.Add(x => x.Name).Descending())

.Read(read => read.Action("GetProductData", "ProductDetails").Type(HttpVerbs.Get))


)



)

ProductDetails controller

public ActionResult GetProductData([DataSourceRequest] DataSourceRequest request)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
return Json(GetAllProductList().ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}

The following will return records but for some reason it would bind to grid in Product details tab

/// <summary>

/// </summary>
/// <returns></returns>
private static IEnumerable<ProductModel> GetAllProductList()
{
using (var dc = new HHEntities())
{
var result = (from a in dc.Products

select new ProductModel
{
ProductId= a.ProductId,
Name= a.Name,
Description= a.Description,
ExpiryDate= a.ExpiryDate


});
return result.Distinct().ToList();
}


}

public ActionResult  _Product()
{
      return PartialView();
}

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 25 Apr 2013, 02:55 PM
Hello David,

I posted my reply in the support ticket you have opened on the same topic. For convenience, I am pasting it below:

The code you provided seems correct. Could you verify that the scripts are correctly included? If they are, please check if there are any JavaScript errors and the response from the server. Also, is the "Index" action returning a PartialViewResult? A problem might occur if a View with the Layout is returned and the scripts are loaded again.


Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or