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

not able to get a reference to the kendo grid for changing the grid properties

0 Answers 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Praseeda
Top achievements
Rank 1
Praseeda asked on 01 Oct 2012, 10:57 AM

I am new to kendoUI and facing a few issues
1. not able to get the grid reference. (for changing the grid properties)
var grd = $("#grid").data("kendoGrid"); // Not working. grd is shown as undefined.

2. DataBound event is not recognized.

Please let me know what i am I missing here.

Please find my code below
<div class="k-content">
@(Html.Kendo().Grid(Model)
      .Name("grid")
      .Columns(columns =>
                   {
                       columns.Bound(company => company.Id).Hidden();
                       columns.Bound(company => company.CompanyName).Sortable(true).Width(120);
                       columns.Bound(company => company.Email).Sortable(true).Width(150);
                       columns.Bound(company => company.CompanyAddressAddress1).Width(120);
                       columns.Bound(company => company.CompanyAddressAddress2).Width(120);
                       columns.Bound(company => company.CompanyAddressCity);
                       columns.Bound(company => company.CompanyAddressStateAbbreviation).Width(80);
                       columns.Bound(company => company.CompanyAddressZip).Width(100);
                       columns.Command(command =>
                                           {
                                               command.Edit();
                                               command.Destroy();
                                           }).Width(180);
                   })
      .ToolBar(toolbar => toolbar.Create())

      .Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("CompanyCreate")
                           .Window(window => window.Title("Company Profile").Name("CompanyEdit"))
      )
      .Groupable()
      .Pageable()
      .Sortable()
      .Scrollable()
      .Filterable()
      .DataSource(dataSource => dataSource
                                    .Ajax()
                                    .ServerOperation(false)
                                    .Events(
                                    events =>
                                    {
                                        //events.Change("");
                                        events.Error("error_handler");                                      
                                        events.DataBound("reload_grid");//gives error
                                    }

    )
        .Model(model => model.Id(company => company.Id))
        .Create(update => update.Action("CompanyCreate", "Company", new { act = "Create" }))
        .Update(update => update.Action("CompanyUpdate", "Company", new { act = "Update" }))
        .Destroy(update => update.Action("CompanyDestroy", "Company"))
    .Read(read => read.Action("CompanyRead", "Company"))
    )
      )
<script type="text/javascript">
    // get a reference to the grid
var grd = $("#grid").data("kendoGrid"); // Not working. grd is shown as undefined.
   
       
    $(".k-grid-add").on("click", function (e) {
    
       var insertMode = e.model.isNew(); //gives error
       
        var window = e.container.data("kendoWindow");//gives error
        e.container.kendoWindow("title", "Add new record");//gives error.      
       
    });

 function reload_grid(e) {
        //alert("reload");
    }
</script>.

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Praseeda
Top achievements
Rank 1
Share this question
or