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

Grid disappears when adding custom command

1 Answer 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 17 Jun 2015, 10:23 PM

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");
    }
}

1 Answer, 1 is accepted

Sort by
0
Tony
Top achievements
Rank 1
answered on 17 Jun 2015, 11:38 PM
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.
Tags
Grid
Asked by
Tony
Top achievements
Rank 1
Answers by
Tony
Top achievements
Rank 1
Share this question
or