2010-12-14 9 views
0

Mit telerik Panel-BarSo erhalten Sie den übergeordneten Wert in dieser Situation (mithilfe der Telerik-Symbolleiste)

Html.Telerik().PanelBar() 
    .Name("PanelBar") 
    .BindTo(Model, mappings => 
    { 
     mappings.For<Category>(binding => binding 
       .ItemDataBound((item, category) => 
       { 
        item.Text = category.CategoryName; 
       }) 
       .Children(category => category.Products)); 
     mappings.For<Product>(binding => binding 
       .ItemDataBound((item, product) => 
       { 
        item.Text = product.ProductName; 
       })); 
    }) 

http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-panelbar-data-binding.html

Was ich brauche eine URL basierend auf categoryID zu erzeugen ist und productID

dh:

.Children(category => category.Products)); 
    mappings.For<Product>(binding => binding 
      .ItemDataBound((item, product) => 
      { 
       item.Text = product.ProductName; 
       item.Url = (Get at the parent to get the categoryid somehow) + "/Details/" + product.productID; 
      })); 

Aber ich kann nicht verstehen aus, wie ich auf die Kategoriefelder zugreifen kann.

Und ich kann es nicht vom Produkt bekommen, weil es eins-viele sein wird, und ich werde product.Categories. linq Methoden

Cheers

haben

Antwort

0

haben Obwohl ich nicht wollte, ich es geschafft, zu speichern, der Wert wie folgt aus:

mappings.For<Category>(binding => binding 
       .ItemDataBound((item, category) => 
       { 
        item.Text = category.CategoryName; 
        item.ActionName = category.CategoryID.ToString(); 
       }) 
       .Children(category => category.Products)); 
     mappings.For<Product>(binding => binding 
       .ItemDataBound((item, product) => 
       { 
        item.Text = product.ProductName; 
        item.Url = item.Parent.ActionName + "/Detail/" + product.ProductID; 
       })); 

Wonder, wenn jemand endet mit einer Reinigungslösung bis