Ehsan Sadeghi
Ehsan Sadeghi

Reputation: 117

Kendo UI grid template column

I have this grid in my page and it works great :

    @(Html.Kendo().Grid<SalaryAdmin.Classes.ReturnedCompareHoghough>()
    .Name("Grid")
    .EnableCustomBinding(true)
    .BindTo(Model.Comparehoghough)
    .Columns(columns => {
        columns.Template(@<text><input type="text" name="@item.MelliCode" class="sel" /></text>).Width(50);

        columns.Bound(o => o.MomayezFinalTax).Format("{0:n0}").Title("مالیات قابل پرداخت پس از اعمال معافیت موضوع ماده 92 (ویژه مناطق کمتر توسعه یافته) نظر ممیز");
        columns.Bound(o => o.FinalTax).Format("{0:n0}").Title("مالیات قابل پرداخت پس از اعمال معافیت موضوع ماده 92 (ویژه مناطق کمتر توسعه یافته)");

    })
    .Pageable()
    .Navigatable()        
    .DataSource(dataSource => dataSource.Server().Total((int)ViewData["totalMoadi"]))
)

I replace that grid with this version :

   @(Html.Kendo().Grid<SalaryAdmin.Classes.ReturnedCompareHoghough>()
                    .Name("Grid").EnableCustomBinding(true).BindTo(Model.Comparehoghough)

    .Columns(columns =>
    {
        columns.Template(@<text><input type="text" name="@item.MelliCode" class="sel" /></text>).Width(50);

        columns.Bound(o => o.MomayezFinalTax).Format("{0:n0}").Title("مالیات قابل پرداخت پس از اعمال معافیت موضوع ماده 92 (ویژه مناطق کمتر توسعه یافته) نظر ممیز").Width(200).ClientFooterTemplate("#=sum#");
        columns.Bound(o => o.FinalTax).Format("{0:n0}").Title("مالیات قابل پرداخت پس از اعمال معافیت موضوع ماده 92 (ویژه مناطق کمتر توسعه یافته)").Width(200).ClientFooterTemplate("#=sum#");
    })
    .Pageable()
   .Scrollable(scr => scr.Height(420))
                     .DataSource(dataSource => dataSource.Ajax().Aggregates(
                         ag =>
                         {
                             ag.Add(h => h.MomayezFinalTax).Sum();
                             ag.Add(h => h.FinalTax).Sum();
                         }
                         ).Read(read => read.Action("ChangeHoghough_Read", "list", new { id = Model.list.GuidList })))
)

it works great too except textbox is not displayed. is it possible to display text in seond version? If yes, How can I get entered value in postback? I tried to get in paging event but in paging event a linq code is posted.

Upvotes: 0

Views: 17489

Answers (2)

Deathstalker
Deathstalker

Reputation: 834

You want something like this.

columns.Template(c => "<input type='text' name='AdminEmail' value='"+  c.Email +"'> ").Title("").Width(140).HtmlAttributes(new { style = "text-align:center; white-space: nowrap; text-decoration: underline;" }).HeaderHtmlAttributes(new { style = "text-align:center; white-space: nowrap;" });

Upvotes: 0

Andrew Merritt
Andrew Merritt

Reputation: 307

I'm assuming the point of the different grids is to move from Server binding to Ajax binding. The text box isn't displayed because you are using the Server Template instead of the client side template. Try this for the column:

columns.ClientTemplate("#: <input type='text' name='MelliCode' class='sel' /> #")...

The syntax is a bit different, here's an overview. I'm not sure but the BindTo Parameter might mean that you are getting the data twice on initial load.

Upvotes: 2

Related Questions