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

unable to bind grid properly

3 Answers 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Imteyaz
Top achievements
Rank 1
Imteyaz asked on 05 Jan 2013, 09:40 AM
Hello I have a grid in my razor view,
I have added these resources
<link rel="stylesheet" href="@Url.Content("~/Content/KendoThemes/kendo.common.min.css")">
    <link rel="stylesheet" href="@Url.Content("~/Content/KendoThemes/kendo.rtl.min.css")">
    <link rel="stylesheet" href="@Url.Content("~/Content/KendoThemes/kendo.default.min.css")">
 
<script src="@Url.Content("~/Scripts/jquery.min.js")"></script>
    <script src="@Url.Content("~/Scripts/kendo.web.min.js")"></script>
    <script src="@Url.Content("~/Scripts/kendo.aspnetmvc.min.js")"></script>


here is my grid

  
@(Html.Kendo().Grid<Nop.Web.Models.Customer.CustomerInfoModel>()
    .Name("Grid")   
    .Columns(columns => {       
        columns.Bound(p => p.Active);
       // columns.Bound(p => p.cbSubscriptions).ClientTemplate("#=Employee.EmployeeName#");
        columns.Bound(p => p.cbSubscriptions);
        columns.Bound(p => p.FirstName);
        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);   
    })   
    .ToolBar(toolBar => toolBar.Create())
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .Pageable()
    .Sortable()
    .Scrollable()
            .DataSource(dataSource => dataSource
                .Ajax()
                .Events(events => events.Error("error_handler"))
                .Model(model => model.Id(p => p.Id))
                        .Create(update => update.Action("EditingInline_Create", "Customer"))
                        .Read(read => read.Action("UsersList", "Customer"))
                .Update(update => update.Action("EditingInline_Update", "Grid"))
                .Destroy(update => update.Action("EditingInline_Destroy", "Grid"))
            )
)
<script type="text/javascript">
    function error_handler(e) {
        if (e.errors) {
            var message = "Errors:\n";
            $.each(e.errors, function (key, value) {
                if ('errors' in value) {
                    $.each(value.errors, function () {
                        message += this + "\n";
                    });
                }
            });
            alert(message);
        }
    }
</script>

This works fine. it calls my action in controller to read the data, but the problem is that, it is displaying any rows in grid, even the controller returns the record. I have checked the console, there is no script error, and my network tab shows that these data has been transferred from the server. 

  1. data[{Email:familymanager1_user1@gmail.com, AllowUsersToChangeUsernames:false, UsernamesEnabled:false,…},…]
    1. 0{Email:familymanager1_user1@gmail.com, AllowUsersToChangeUsernames:false, UsernamesEnabled:false,…}
    2. 1{Email:familymanager1_user2@gmail.com, AllowUsersToChangeUsernames:false, UsernamesEnabled:false,…}
    3. 2{Email:familymanager1_user3@gmail.com, AllowUsersToChangeUsernames:false, UsernamesEnabled:false,…}
    4. 3{Email:as@sad.com, AllowUsersToChangeUsernames:false, UsernamesEnabled:false, Username:aasasasasas687,…}
  2. total4

Am I missing something to add. 

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 07 Jan 2013, 07:50 AM
Hello Imteyaz,

Looking at the format of the JSON response, it suspect that the controller action implementation is not correct. Please refer to this help article which describes how to populate the KendoUI Grid for ASP.NET MVC via AJAX and verify that your action uses the same approach.

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
srilatha
Top achievements
Rank 1
answered on 31 Aug 2016, 07:30 AM
Unable to bind grid properly, can you please help me , it's very urgent
0
Rosen
Telerik team
answered on 31 Aug 2016, 11:40 AM

Hello srilatha,

Looking at the provided information. I'm not sure neither what the problem is nor how the widget is configured. Please open a separate support request in which provide as much details as possible about your scenario, the behavior you are experiencing, the expected result and if possible a small runnable sample which to demonstrate it locally. 

Regards,
Rosen
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Imteyaz
Top achievements
Rank 1
Answers by
Rosen
Telerik team
srilatha
Top achievements
Rank 1
Share this question
or