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

[Solved] Row client selection and ajax binding problems

2 Answers 120 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.
Adriano
Top achievements
Rank 1
Adriano asked on 21 Apr 2011, 06:28 PM
Hi all, we have followed your demo http://demos.telerik.com/aspnet-mvc/razor/grid/selectionclientside for using client selection in a master grid and updating data in a detail grid. But, after the initial binding, all the following ajax operations (sorting, paging, refresh) on the detail grid are returning no data. In your sample happens the same thing (for example, if you select the customer id GREAL and go to the page 2 in the orders grid, this page is empty).

Does it exist a solution to that?  

2 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 22 Apr 2011, 07:38 AM
Hi Adriano,

Indeed, you are correct in your observation. In order to achieve the desired functionality you should use the databinding event of the child grid to pass the selected id. I have attached a modified version of the View from the example in order to illustrate this.

Best wishes,
Rosen
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
Staci
Top achievements
Rank 1
answered on 25 Jul 2012, 03:32 PM
I have also been trying to follow the SelectionClientSide code but have not had much luck getting it to work. The main difference I can see is that Northwind tables Customers and Orders are related by the CustomerID which is a string, my tables are connected by an integer ID. The code held in the SelectionClientSideController is this:
[GridAction]
        public ActionResult _SelectionClientSide_Orders(string customerID)
        {
            customerID = customerID ?? "ALFKI";
 
            return View(new GridModel<Order>
            {
                Data = GetOrdersForCustomer(customerID)
            });
        }

if I change it to take an integer like this:
[GridAction]
        public ActionResult _SelectionClientSide_Campaigns(int clientID)
        {
            clientID = clientID ??  1;
             
            return View(new GridModel<tbl_Campaign>
            {
                Data = GetCampaignsForClient(clientID)
            });
        }

I get the following error message - Operator '??' cannot be applied to operands of type 'int' and 'int'. I have tried to check for a null by using an if statement like this:
[GridAction]
        public ActionResult _SelectionClientSide_Campaigns(int clientID)
        {
           if (clientID == null)
            {
                clientID = 1;
            }
             return View(new GridModel<tbl_Campaign>
            {
                Data = GetCampaignsForClient(clientID)
            });
        }

which doesn't give me an error message but my grids are empty. I'm obviously missing something, but not sure what. Another thing I have noticed throughout the MVC examples solution is the namespace "using Models" is used but I'm not sure what this is. Is this referring to the Models folder? Also for this demo, is a Model being used, if so which one because I can't figure out where it is.

All files involved are attached.

Many thanks
Staci
Tags
Grid
Asked by
Adriano
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Staci
Top achievements
Rank 1
Share this question
or