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

No data display on inline editing grid

3 Answers 149 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anieda Hom
Top achievements
Rank 1
Anieda Hom asked on 21 Sep 2017, 04:06 PM

I want to use inline server editing grid.  But the grid does not load any data.  Can't figure out what is missing.

Here is the code:

Index.cshtml page

@using Kendo.Mvc.UI

@using (Html.BeginForm("AddUser", "Contact"))
{
      @Html.AntiForgeryToken()
     <fieldset>
           <legend>Add User</legend>
           Please enter minimum 3 letters to search.
              <div>
@(Html.Kendo().ComboBox()
.Name("NewUser")
.DataTextField("DisplayName")
.DataValueField("Snumber")
.Filter(FilterType.StartsWith)
.MinLength(3)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("Search", "Contact");
}).ServerFiltering(true);
})
)
<input type="submit" name="AddUser" value="AddUser" />
<div class="AddUserError">@TempData["AddUserError"]</div>
</div>
</fieldset>
}

@{
Html.Kendo().Grid<CCC.ITSChangeControl.Models.ViewModels.GridContactViewModel>().Name("grid").Columns(columns =>
{
        columns.Bound(contact => contact.FullName);
columns.Bound(contact => contact.Admin);
columns.Bound(contact => contact.Approver);
columns.Bound(contact => contact.Active);
columns.Bound(contact => contact.Id).Visible(false);
columns.Bound(contact => contact.Snumber).Visible(false);
columns.Command(command =>
{
command.Edit();
command.Destroy();
}).Width(250);
})            
}

3 Answers, 1 is accepted

Sort by
0
Anieda Hom
Top achievements
Rank 1
answered on 21 Sep 2017, 04:10 PM

Sorry, this is the grid:

@{
Html.Kendo().Grid<CCC.ITSChangeControl.Models.ViewModels.GridContactViewModel>().Name("grid").Columns(columns =>
{
columns.Bound(contact => contact.FullName);
columns.Bound(contact => contact.Admin);
columns.Bound(contact => contact.Approver);
columns.Bound(contact => contact.Active);
columns.Bound(contact => contact.Id).Visible(false);
columns.Bound(contact => contact.Snumber).Visible(false);
columns.Command(command =>
{
command.Edit();
command.Destroy();
}).Width(250);
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Server()
.Model(model => model.Id(contact => contact.Id))
//.Create("Create", "Contact")
.Read(read => read.Action("Index", "Contact"))
//.Update("Update", "Contact")
//.Destroy("Destroy", "Contact")
);
}

Here is the Controller:

public ActionResult Index()
{
List<GridContactViewModel> gcvm = ChangeControlService.GetContactViewModels(this.context);
return this.View("Index", gcvm);
}

Thanks advance for your help!

 

0
Anieda Hom
Top achievements
Rank 1
answered on 21 Sep 2017, 04:13 PM

Sorry, here is the grid in details:

@using Kendo.Mvc.UI

@using (Html.BeginForm("AddUser", "Contact"))
{
@Html.AntiForgeryToken()
<fieldset>
<legend>Add User</legend>
Please enter minimum 3 letters to search.
<div>
@(Html.Kendo().ComboBox()
.Name("NewUser")
.DataTextField("DisplayName")
.DataValueField("Snumber")
.Filter(FilterType.StartsWith)
.MinLength(3)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("Search", "Contact");
}).ServerFiltering(true);
})
)
<input type="submit" name="AddUser" value="AddUser" />
<div class="AddUserError">@TempData["AddUserError"]</div>
</div>
</fieldset>
}

@{
Html.Kendo().Grid<CCC.ITSChangeControl.Models.ViewModels.GridContactViewModel>().Name("grid").Columns(columns =>
{
columns.Bound(contact => contact.FullName);
columns.Bound(contact => contact.Admin);
columns.Bound(contact => contact.Approver);
columns.Bound(contact => contact.Active);
columns.Bound(contact => contact.Id).Visible(false);
columns.Bound(contact => contact.Snumber).Visible(false);
columns.Command(command =>
{
command.Edit();
command.Destroy();
}).Width(250);
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Server()
.Model(model => model.Id(contact => contact.Id))
//.Create("Create", "Contact")
.Read(read => read.Action("Index", "Contact"))
//.Update("Update", "Contact")
//.Destroy("Destroy", "Contact")
);
}

Here is the controller:

public ActionResult Index()
{
List<GridContactViewModel> gcvm = ChangeControlService.GetContactViewModels(this.context);
return this.View("Index", gcvm);
}

Thanks in advance for your help!!!

0
Stefan
Telerik team
answered on 25 Sep 2017, 10:43 AM
Hello, Anieda,

Thank you for the provided information.

The code looks good by I can assumе, that there is may be an issue with the data format.

I can suggest checking our article demonstrating the required steps:

http://docs.telerik.com/aspnet-mvc/helpers/grid/binding/server-binding

Also, we have a runnable example which can be used for reference:

https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/server-binding

And two demos:

http://demos.telerik.com/aspnet-mvc/grid/serverbinding

http://demos.telerik.com/aspnet-mvc/grid/customserverbinding

If the issue still occurs, please send a fully runnable example and we will gladly assist.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Anieda Hom
Top achievements
Rank 1
Answers by
Anieda Hom
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or