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

[Solved] Trying to get In-cell editing working

12 Answers 91 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.
Donavan
Top achievements
Rank 1
Donavan asked on 02 Jun 2011, 04:16 PM
On my current project we have a need to allow the user to edit various lookup tables that have different column counts and datatypes. In order to avoid creating custom code for each lookup table I've set my view up to accept a DataTable and set the grid columns based off of the columns in the table.  The problem I have is that the grid doesn't switch to edit mode, nor does it throw any errors or complain in the javascript console.  At this point I'm at a loss as to how to proceed since I have no hints as to what's causing this behavior.

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

Sort by
0
Atanas Korchev
Telerik team
answered on 03 Jun 2011, 08:30 AM
Hi Donavan,

 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,

Atanas Korchev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Donavan
Top achievements
Rank 1
answered on 03 Jun 2011, 02:59 PM
I've attached a simple project that demonstrates the issue using the Northwind employees table.  I've tried several variations again this morning with no luck. 
0
Atanas Korchev
Telerik team
answered on 06 Jun 2011, 08:08 AM
Hello Donavan,

 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. 

Regards,
Atanas Korchev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Donavan
Top achievements
Rank 1
answered on 06 Jun 2011, 01:21 PM
They were left out because they weren't germane to the problem.  It never attempts to call either of the URLS.  But I'll package up another zip with them in it if you think it'd help.
0
Donavan
Top achievements
Rank 1
answered on 06 Jun 2011, 01:30 PM
Actually the only one missing is the actual save handler...  Though I forgot to change the controller name for the actions in the grid declaration for index.aspx.  Adding them had no impact at all on the core problem of not being able to enter edit mode.
0
Atanas Korchev
Telerik team
answered on 06 Jun 2011, 02:07 PM
Hello Donavan,

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
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 Public Issue Tracking system and vote to affect the priority of the items
0
Donavan
Top achievements
Rank 1
answered on 06 Jun 2011, 02:48 PM
Unfortunately the interface I'm building is to maintain a bunch (100 or so) lookup tables containing 1-3 columns of varying types so while I *could* create types for these can pass them, a generic solution is preferable.  That being said, the "About" action attempts to display the same grid using LINQ to SQL and exhibits the same behavior.

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.
0
Atanas Korchev
Telerik team
answered on 06 Jun 2011, 02:53 PM
Hello Donavan,

 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
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 Public Issue Tracking system and vote to affect the priority of the items
0
Donavan
Top achievements
Rank 1
answered on 06 Jun 2011, 03:32 PM
Sorry about that, I must have added those in my attempts to find a solution after I'd sent the original zip.  Here's the updated project that uses generic data tables in index and linq in the about action.
0
Donavan
Top achievements
Rank 1
answered on 06 Jun 2011, 03:33 PM
It might also be helpful to note that I have no issues doing this from C#.  The examples all work. there's just something I'm apparently screwing up in the VB versions.
0
Atanas Korchev
Telerik team
answered on 07 Jun 2011, 08:57 AM
Hello Donavan,

 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) _


In that case the editing will not work because the column editors generated by ASP.NET MVC do not work with data tables. As I said before you need some extra steps. Check my previous reply and the code library project which shows how to implement editing when bound to data table.

Regards,
Atanas Korchev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Donavan
Top achievements
Rank 1
answered on 07 Jun 2011, 01:18 PM
Ok... JQGrid is is then.
Tags
Grid
Asked by
Donavan
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Donavan
Top achievements
Rank 1
Share this question
or