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

Data wont show (Client Detail Template)

1 Answer 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Harya
Top achievements
Rank 1
Harya asked on 22 Sep 2017, 03:31 AM

hello everyone , im just start learning with mvc 2 weeks ago, and decide to using telerik, and now i have some problem while using client detail template , after im running the code the data wont show up. please help. ( see my attachment ) , and i've attach my model if necessary

my controller :

namespace TelerikMvcApp2.ControllersTelerik
{
 
    public class TelerikHeaderController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }
 
        public ActionResult Lines_Read([DataSourceRequest]DataSourceRequest request)
        {
            using (var saleorder = new SaleorderEntities1())
            {
                IQueryable<Line> lines = saleorder.Lines;
                DataSourceResult result = lines.ToDataSourceResult(request, line => new
                {
                    line.LineID,
                    line.ProductID,
                    line.Quantity,
                    line.Unit,
                    line.TotalPrice
                });
 
                return Json(result);
 
            }
 
        }
 
        public ActionResult Headers_Read([DataSourceRequest]DataSourceRequest request, int lineId)
        {
            using (var saleorder = new SaleorderEntities1())
            {
                IQueryable<Header> headers = saleorder.Headers.Where(header => header.LineID == lineId);
 
                DataSourceResult result = headers.ToDataSourceResult(request, header => new
                {
                    header.HeaderID,
                    header.CustomerID,
                    header.TotalAmount,
                    header.LineID
 
                });
 
                return Json(result);
 
            }
        }
 
        
 
    
  }

 

View :

@(Html.Kendo().Grid<TelerikMvcApp2.Models.Header>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(header => header.LineID);
        columns.Bound(header => header.HeaderID);
        columns.Bound(header => header.CustomerID);
        columns.Bound(header => header.TotalAmount);
    })
    .DataSource(dataSource =>
        dataSource.Ajax().Read(read => read.Action("Headers_Read", "TelerikHeader"))
        )
    .ClientDetailTemplateId("client-template")
    )
 
<script id="client-template" type="text/x-kendo-template">
    @(Html.Kendo().Grid<TelerikMvcApp2.Models.Line>()
        .Name("grid_#=LineID#")
        .Columns(columns =>
        {
            columns.Bound(line => line.ProductID);
            columns.Bound(line => line.Quantity);
            columns.Bound(line => line.Unit);
            columns.Bound(line => line.TotalPrice);
        })
        .DataSource(dataSource =>
        dataSource.Ajax().Read(read => read.Action("Lines_Read","TelerikHeader", new {linesId ="#=LinesID#"}))
        )
        .Pageable()
        .ToClientTemplate()    
    )
</script>

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 25 Sep 2017, 11:39 AM
Hello, Harya,

Thank you for the provided information.

I inspected the code and all looks good, I can assume that there is an issue with the data format.

Could you please check the response which is received from the server?.

I can suggest inspecting the response from our demo in order to observe the expected format and check if there are any differences comparing it to the real example:

http://demos.telerik.com/aspnet-mvc/grid/hierarchy

http://docs.telerik.com/aspnet-mvc/helpers/grid/templating/client-detail-template

If the issue still occurs, please provide an example reproducing the issue and we will gladly assist further.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Harya
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or