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

[Solved] Unable to implement Ajax Editing delete commang

1 Answer 84 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.
Narayanarao
Top achievements
Rank 1
Narayanarao asked on 23 Jan 2012, 02:05 PM

Hi Team,

        I am trying to use delete button in the grid using Ajax databinding. Below is the code snippet which I use, with this grid is populating data properly but when I click on delete button it is asking 'are you sure you want to delete this record?'. After clicking on ok it is giving javascript error saying 'Profile.AccountNumber' is null or not an object error message.
@(Html.Telerik().Grid(Model.PartnerDetails.SubPartnersList).Name("PartnerManagement")
     .DataKeys(keys => keys.Add(o => o.Profile.AccountNumber))
     .DataBinding(dataBinding => 
         
             dataBinding.Ajax()
                 .Delete("DeletePartner", "PartnerManagement"); 
         })
     .Columns(columns =>
         {
             columns.Bound(o => o.Profile.CompanyName).Title(ViewResources.PartnerManagement.GetSubPartnerList.PartnerName);
             columns.Bound(o => o.Addresses.BillingAddress.StateProvinceCode).Title(ViewResources.PartnerManagement.GetSubPartnerList.State);
             columns.Bound(o => o.Addresses.BillingAddress.CountryCode).Title(ViewResources.PartnerManagement.GetSubPartnerList.Country);
             columns.Bound(o => o.SellerDetails.PartnerTypeCode).Title(ViewResources.PartnerManagement.GetSubPartnerList.PartnerType);
             columns.Command(commands => 
                               
                                 commands.Delete(); 
                               }
                            ).Width(180).Title("");
         })
       .ClientEvents(e => e.OnLoad("customizeTelerikGridFilter"))
       .Pageable()
       .Sortable(sorting => sorting
       .OrderBy(sortOrder => sortOrder.Add(o => o.Profile.CompanyName).Ascending()))
       .Filterable()
   )

    Please help in soving this problem. Here I am trying to bind to a model with 2 levels of list items in it. Is it causing  the problem because I am assigning a property in the second level of a list ?   

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 25 Jan 2012, 12:57 PM
Hi Narayanarao,

There shouldn't be a problem to bind a column to a property of the inner object. However, the DataKey should be a property of the model itself. You should use a View Model in which AccountNumber is a property of the model.

Kind regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
Narayanarao
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or