Grid disappears when adding custom command

2 posts, 0 answers
  1. Tony
    Tony avatar
    7 posts
    Member since:
    Apr 2015

    Posted 17 Jun 2015 Link to this post

    I'm new to Kendo UI MVC controls. I'm using a couple of grids inside a tabstrip. When I add a custom command to one of the grids, the grid does not render onto the page, but when I remove the custom command, it renders and displays the data as expected. Can anyone help? any help is greatly appreciated. My code is as follows.

     

    <div id="jobstabdiv">
        @(Html.Kendo().TabStrip()
              .Name("Jobstabstrip")
              .Events(events => events
                .Select("selecttab"))
              .Items(tabstrip =>
              {
                  tabstrip.Add().Text("Job Runs")
                      .Selected(true)
                      .Content(@<text>@RenderRunGrid()</text>);

                  tabstrip.Add().Text("Incoming Files")
                      .Content(@<text>@RenderInFilesGrid()</text>);

              })
              .Events(tab => tab.Show("capturecurrenttab"))
        )
    </div>

    @helper RenderRunGrid()
    {
        @(Html.Kendo().Grid<WI20Web.Models.RunsViewModel>()
            .Name("rungrid")
            .Columns(columns =>
            {
                columns.Command(command => command.Custom("status").Click("chgstatus"));
                columns.Bound(p => p.Id).Filterable(false).Width(50);
                columns.Bound(p => p.Mailshop_Job_Id).Width(200).Title("Mailshop Job Id");
                columns.Bound(p => p.Application_Id).Width(200).Title("App Id");
                columns.Bound(p => p.Application_Name).Title("App Name");
                columns.Bound(p => p.Status).Width(200);
                columns.Bound(p => p.Work_Order).Width(200).Title("Work Order");
                columns.Bound(p => p.Status).Hidden(true).ClientTemplate("<div class='run-status-#= Status#'></div>");
            })
            .Pageable()
            .Sortable()
            .Scrollable()
            .Filterable()
            .Groupable()
            .HtmlAttributes(new { style = "height:650px;" })
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(10)
                .Read(read => read.Action("List_Data", "Runs"))
            )
            .Resizable(resize => resize.Columns(true))
            .Reorderable(reorder => reorder.Columns(true))
            .Events(events => events.DataBound("hilite_runs"))
        )
    }

    @helper RenderInFilesGrid()
    {
        @(Html.Kendo().Grid<WI20Web.Models.IncomingFileViewModel>()
            .Name("infilesgrid")
            .Columns(columns =>
            {
                columns.Bound(p => p.File_Path).Title("File Path");
                columns.Bound(p => p.File_Name).Title("File Name");
                columns.Bound(p => p.Date_Received).Title("Date Received").Format("{0:MM/dd/yyyy hh:mm:ss}");
                columns.Bound(p => p.File_Size).Title("File Size");
            })
            .Pageable()
            .Sortable()
            .Scrollable()
            .Filterable()
            .Groupable()
            .HtmlAttributes(new { style = "height:650px;" })
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(10)
                .Read(read => read.Action("List_Data", "InFiles"))
            )
            .Resizable(resize => resize.Columns(true))
            .Reorderable(reorder => reorder.Columns(true))
        )
    }

    @section scripts
    {
        function chgstatus(e) {
        alert("Change Status");
        }
    }

  2. Tony
    Tony avatar
    7 posts
    Member since:
    Apr 2015

    Posted 17 Jun 2015 in reply to Tony Link to this post

    I think I figured out my own problem. Seems I had a javascript function I was trying to call for the click event in the wrong place, so it couldn't be found. It's working now.
Back to Top