Here's the code I'm using to set up my grid (client mandated VB):
Dim gridBuilder = Html.Telerik().Grid(Model) _ .Name("TankGrid") _ .DataBinding(Function(dataBinding) dataBinding.Ajax().[Select]("_SelectBatchEditing", "SysAdmin", New With {.tableName = ViewBag.TableName}).Update("_SaveBatch", "SysAdmin", New With {.tableName = ViewBag.TableName}) ) _ .Editable(Sub(editing) editing.Mode(GridEditMode.InCell)) gridBuilder.Columns(sub(columns) For Each column As System.Data.DataColumn In Model.Columns columns.Bound(column.DataType, column.ColumnName) Next End sub) _ .Scrollable(Function(c) c.Height("120px")) _ .Selectable() gridBuilder.Render()12 Answers, 1 is accepted
Your code snippet looks correct. We are also at a loss why it is not working. You can check if all the required JavaScript files are loaded at all. Also check if there is a ScriptRegistrar in your page.
Regards,
the Telerik team
Your project does not contain an action method which will bind the grid (_SelectBatchEditing). I also does not contain the action method which will save the data(_SaveBatch). Without those methods you cannot achieve batch editing.
Atanas Korchev
the Telerik team
You are using DataTable instead of strongly typed collections. Is this mandatory for your project? If you need to use DataTable you should manually set the editor for every column as in this code library project.
Still batch editing requires strongly typed objects so ASP.NET MVC can populate them during update action method:
[GridAction]public ActionResult Update(IEnumerable<Customer> inserted, IEnumerable<Customer> updated, IEnumerable<Customer> deleted)In short there are two ways to deal with this situation:
1) Set the name editor template for every column as demonstrated in this code library project. Create strongly typed object (Employee in this case) which will be used by the update action method.
2) Bind the grid to a collection of strongly typed objects. You can use Linq2SQL, Entity Framework or any other ORM which supports linq. Regards,
Atanas Korchev
the Telerik team
I'm not married to batch updates, ajax editing is fine. Right now I can't even edit the data to TRY and save it.
I am not sure what you mean. The sample project which you provided contains the following definition for the About method:
Function About() As ActionResult
Return View()
End Function
Did you check the code library project which I mentioned in my previous reply? It demonstrates how to implement editing with a DataTable object.
Regards,
Atanas Korchev
the Telerik team
Your grid is again bound to a datatable:
<%@ Page Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage(of system.data.datatable)" %>
<% Dim gridBuilder = Html.Telerik().Grid(Model) _
Atanas Korchev
the Telerik team