0

I have a grid that displays the Orders from customers, it contains an ItemID in it. Now, im using the telerik grid for mvc to perform CRUD operations on the second grid, for the column of ItemID i use ForeignKey with no problems just like this code:

cols.ForeignKey(c => c.ItemID, (System.Collections.IEnumerable)ViewData["rcItems"],
                    "ItemID", "Name").Width(200).Title("Description");

Now my problem was everytime i perform an edit, ALL of the Items will be shown from the dropdown. what i wanted was display only the items available that will depend on the customer on the grid. In other words, customer1 may only get(100, 101), customer2(100) and customer3(102, 103)

I have two tables CustomerOrders and DeliveredItemstoCustomers

--CustomerOrders table
CustomerID      ItemID
1                     100
1                     101
2                     100
3                     102
3                     103

--Item table
ItemID   Name
100      Apple
101      Orange
102      Banana
103      Grapes

--DeliveredItemstoCustomers Table
CustomerID      ItemID
1                     101
3                     103

--How I load the Items to Viewdata
ViewData["rcItems"] = db.Items.ToList();

Basically, i want to prevent the user to enter an item not available for the selected user. I'm trying to change the Viewdata on client side using ajax, but no luck

Thanks

samantha07
  • 507
  • 1
  • 7
  • 21

1 Answers1

0

Any chanches to apply ForeignKey on a dynamic binded grid?

Ras
  • 628
  • 1
  • 11
  • 29