ClientTemplate doesn't work on a grid

2 posts, 0 answers
  1. roukfa
    roukfa avatar
    8 posts
    Member since:
    Nov 2018

    Posted 01 Oct 2019 Link to this post

    Hi, I've got a problem with clientTemplate on my grid. I'm not fetching data from server. When I try to switch to Template, it throws an exception. This is my code :

     @(Html.Kendo().Grid<PRR405.ViewModels.BatchViewModel>(Model.LotsOuverts)
                    .Name("LotsOuvert")
                    .Columns(columns =>
                    {
                        columns.Bound(p => p.Post_date).Title(PRR405.Resources.OpenLot.OpenLot.DateDOuverture).Format("{0: yyyy/MM/dd}").Width(150).Filterable(f => f.UI("DatePickerFormated"));
                        columns.Bound(p => p.Btch_num).Title(PRR405.Resources.OpenLot.OpenLot.NumLotPRR).ClientTemplate(@"<a href='/ResumeLot/ResumeLot?btchNum=#: Btch_num #'>#: Btch_num #</a>").Width(170);
                        columns.Bound(p => p.Comp_num).Title(PRR405.Resources.OpenLot.OpenLot.Assureur).Width(110);
                        columns.Bound(p => p.Br_cd).Title(PRR405.Resources.OpenLot.OpenLot.SuccursaleLabel).Width(120);
                        columns.Bound(p => p.Batch_cd).Title(PRR405.Resources.OpenLot.OpenLot.CodeDeLot).Width(120);
                        columns.Bound(p => p.Entry_Date_Formated).Title(PRR405.Resources.OpenLot.OpenLot.DateInscription).Width(160);
                        columns.Bound(p => p.Batch_type_Name).Title(PRR405.Resources.OpenLot.OpenLot.TypeDeLot).Width(140);
                        //columns.Bound("").Title(PRR405.Resources.OpenLot.OpenLot.ImprimerResume).ClientTemplate(string.Format(@"<a href='/OpenLot/PrintLot?btchNum=#: Btch_num #'>{0}</a>", PRR405.Resources.OpenLot.OpenLot.Imprimer)).Filterable(false);
                    })
                    .Scrollable(s => s.Height("100%"))
                    .HtmlAttributes(new { style = "max-height: 333px; margin-bottom:20px;" })
                    .Sortable()
                    .Scrollable()
                    .Filterable(f => f.Extra(false).Operators(o => o.ForString(str => str.Clear().IsEqualTo(PRR405.Resources.Shared.Shared.GridFiltre_EstEgaleA).IsNotEqualTo(PRR405.Resources.Shared.Shared.GridFiltre_NestPasEgaleA))))
                    .Resizable(resize => resize.Columns(true))

     

    Thank you for your help

  2. Georgi
    Admin
    Georgi avatar
    685 posts

    Posted 03 Oct 2019 Link to this post

    Hello Farouk,

    Since you are using server binding, the whole table is generated on the server, thus, it is not possible to use client template. Instead you should use a Template as follows:

                        columns.Bound(p => p.Btch_num).Title(PRR405.Resources.OpenLot.OpenLot.NumLotPRR).Template(<text>
    <a href='/ResumeLot/ResumeLot?btchNum=@item.Btch_num'>@item.Btch_num</a>
    </text>).Width(170);

    I hope this helps.

    Regards,
    Georgi
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top