We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

editing doesnt work when columns are auto generated

Thread ID:

Created:

Updated:

Platform:

Replies:

141235 Nov 30,2018 11:54 AM UTC Dec 3,2018 07:12 AM UTC ASP.NET MVC 2
loading
Tags: Grid
Emil
Asked On November 30, 2018 11:54 AM UTC

Hi,

if I dont define like below, if i try to edit any row not first row, it always edits first row. Beside that I try to persist data to server but my item object is always empty. is there something I do wrong?

thanks,

Emil

@(Html.EJ().Grid<Models.Db.App>("Grid")
                    .Datasource((IEnumerable<Models.Db.Item>)Model) 
               .Datasource(dataSource => dataSource.Json((IEnumerable<Models.Db.Item>)Model).UpdateURL("Items/Edit")
                .InsertURL("Items/Create").RemoveURL("Items/Delete").Adaptor(AdaptorType.RemoteSaveAdaptor))
       .AllowSorting()
       .AllowFiltering()

         .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().ShowDeleteConfirmDialog(); })
          .ToolbarSettings(toolbar =>
          {
              toolbar.ShowToolbar().ToolbarItems(items =>
              {
                  items.AddTool(ToolBarItems.Add);
                  items.AddTool(ToolBarItems.Edit);
                  items.AddTool(ToolBarItems.Delete);
                  items.AddTool(ToolBarItems.Update);
                  items.AddTool(ToolBarItems.Cancel);
              });
          })
)


   public async Task<ActionResult> Edit(Item item)
        {
            if (ModelState.IsValid)
            {
                 
            }
            return View(item);
        }

Emil
Replied On November 30, 2018 04:55 PM UTC

Ok I figured out. parameter name should value always. i think that this needs to be highlighted in the documentation better for the newbies like me.

Vignesh Natarajan [Syncfusion]
Replied On December 3, 2018 07:12 AM UTC

Hi Emil, 
 
Thanks for using Syncfusion products. 
 
Query1: “if i try to edit any row not first row, it always edits first row” 
 
From your query, we understand that you are not able to edit the Grid rows properly. From your code example, we have found that you rendered the Grid with autoGenerated column. So IsPrimaryKey property is not assigned to any of the available column. This is the cause of the issue. 
 
Refer below link for our knowledge base document for the importance of PrimaryKey property in ejGrid while editing. 
 
 
Also refer the below UG document how to define the PrimaryKey for autogenerated column.  
 
 
Query2: Beside that I try to persist data to server but my item object is always empty. ” 
 
By default while editing, we have passed the model values using property called “value”. So we suggest you to define the parameter as value in the server side.  
 
Refer the modified code example 
 
 public async Task<ActionResult> Edit(Item value) 
        { 
            if (ModelState.IsValid) 
            { 
                  
            } 
            return View(item); 
        } 
 
 
Refer our UG documentation for your reference 
 
 
Please get back to  us if you have further queries. 
 
Regards, 
Vignesh Natarajan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;