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

After sorting the table with AJAX request the Select Command loses its data key.

0 Answers 49 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.
Eric Marshall
Top achievements
Rank 1
Eric Marshall asked on 09 Feb 2011, 07:18 PM
Here is what the "Select" Command looks like on initial load:
"/Customers/CustomerDetails/3?CustomerList-mode=select
 
It looks the same after the sorting request; however,
"/Customers/CustomerDetails/3?CustomerList-mode=select
 
if you hover over or click on the Select control it return this:
"/Customers/CustomerList#"




Razor View Code snippet;

@(Html.Telerik().Grid(Model)
            .TableHtmlAttributes(new { style = "height: 58px;" })
        .Name("CustomerList")
        .Scrollable(c => c.Height("400px"))
        .Resizable(resizing => resizing.Columns(true))
        .Columns(columns =>
        {
            columns.Command(commands =>
            {
                commands.Select();
 
            }).Width(100).Title("Action");
            columns.Bound(c => c.FirstName).Width(100);
            columns.Bound(c => c.LastName).Width(100);
            columns.Bound(c => c.PhoneNumber).Width(100);
            columns.Bound(c => c.CellNumber).Width(100);
            columns.Bound(c => c.EmailAddress).Width(100);
            columns.Bound(c => c.AddressLineOne).Width(100);
            columns.Bound(c => c.AddressLineTwo).Width(100);
            columns.Bound(c => c.City).Width(75);
            columns.Bound(c => c.State).Width(50);
            columns.Bound(c => c.ZipCode).Width(50);
            columns.Bound(c => c.SalesPerson).Width(100);
            columns.Bound(c => c.CustomerPhase).Width(100);
            columns.Bound(c => c.CustomerCreationDate).Width(100);
            columns.Bound(c => c.CustomerID).Hidden();
        })
 
        .DataKeys(keys =>
        {
            keys.Add(c => c.CustomerID);
        })
        .DataBinding(dataBinding =>
        {
             
            dataBinding.Server()
                .Select("CustomerDetails", "Customers");
 
            dataBinding.Ajax()
                .Select("_CustomerList", "Customers");
        })
        .Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
        .Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
        .Pageable(paging => paging.Enabled((bool)ViewData["paging"]))
        .Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
        .Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
        
        .Footer((bool)ViewData["showFooter"])
)

Controller
Repository Code for Model
        private JsonResult GetView()
        {
            JsonResult json = Json(CustomerRepository.getListOfCustomers());
            return Json(CustomerRepository.getListOfCustomers());
        }
 
Initial List and Ajax List Action
        public ActionResult CustomerList(bool? ajax, bool? scrolling, bool? paging, bool? filtering, bool? sorting,
          bool? grouping, bool? showFooter)
        {
 
            ViewData["ajax"] = ajax ?? true;
            ViewData["scrolling"] = scrolling ?? true;
            ViewData["paging"] = paging ?? true;
            ViewData["filtering"] = filtering ?? true;
            ViewData["grouping"] = grouping ?? true;
            ViewData["sorting"] = sorting ?? true;
            ViewData["showFooter"] = showFooter ?? true;
 
 
            return View(CustomerRepository.getListOfCustomers());
        }
 
        [GridAction]
        [HttpPost]
        public ActionResult _CustomerList()
        {
            return GetView();
        }
Tags
Grid
Asked by
Eric Marshall
Top achievements
Rank 1
Share this question
or