2017-07-31 27 views
0

我使用業務包樹視圖組件進行菜單。我的目標是隻檢索沒有子類別的頂級菜單。子類別將僅在用戶圖標點擊(+/- 圖標)或菜單項點擊時顯示。在TreeView上單擊加載子類別Dotvvm

所以基本上當我點擊綁定到這個菜單對象的「a」或圖標時,我想要發送請求到我的服務器來獲取他的子類別等等。我不想在一個請求中獲得所有內容。

enter image description here

正如我注意到有鑑於兩個click處理程序。

1)使用Changed屬性 - 當我使用這個屬性來處理click事件,我順利拿到正確的對象爲我CategorySelectedList,但它只是直接的文本標籤上的點擊次數。對於圖標,它不再工作,類別菜單也不會擴展。

2)使用Events.Click屬性 - 當我使用這個屬性來處理點擊事件。我甚至沒有將正確的對象放入我的CategorySelectedList屬性中,但在這種情況下類別菜單將會擴大。

我無法從我的視圖中發送對象ID到SetActiveMenuNode方法,所以我必須直接從我的CategorySelectedList,但每個aproach有他自己的問題。

有沒有解決方案?

模型視圖

public List<CategoryListDTO> AdminMenuList { get; set; } = new List<CategoryListDTO>(); 
public List<CategoryListDTO> AdminMenuSelectedList { get; set; } = new List<CategoryListDTO>(); 
public void SetActiveMenuNode() 
{ 
    var selected = AdminMenuSelectedList.FirstOrDefault(); 
} 

//načítání podkategorií 
public StaticCommandBindingExpression LoadChildren { get; set; } = new StaticCommandBindingExpression(new CompiledBindingExpression(//something here)); 

我的觀點

<dot:Content ContentPlaceHolderID="MainContent"> 
<section class="content"> 
    <bp:TreeView DataSource="{value: AdminMenuList}" 
       SelectedValues="{value: AdminMenuSelectedList}" 
       ItemKeyBinding="{value: Id}" 
       ItemHasChildrenBinding="{value: HasCategories}" 
       ItemChildrenBinding="{value: AssignedToCategory}" 
       LoadChildren="{staticCommand: _parent.MyMethod()}" 
       Changed="{command: SetActiveMenuNode()}"   
       > 
     <p>{{value: Name}}</p> 
    </bp:TreeView> 
</section> 

回答

1

不幸的是沒有解決辦法現在。我們在我們的待辦事項中有此功能,並將儘可能實施。

我們已經在版本1.1.5-rc1中實現了這個特性。 TreeView控件具有類型的新屬性LoadChildren。這裏是一個如何使用它的例子。

ViewModel.cs

[AllowStaticCommand] 
public static IEnumerable<Item> LoadChildren(Item parent) 
{ 
    return LoadYourChildrenFromSomewhere(parent.Id); 
} 

View.dothtml

<bp:TreeView LoadChildren="{staticCommand: ViewModel.LoadChildren(_this)}" /> 

請注意,DI尚不支持靜態命令(這是coming)。您需要自己創建所需的服務或從全球服務提供商解決它們。

+0

好的,謝謝你的回答。 – Martin

+0

我對你有個好消息。該功能將在下一個測試版本中提供。 –

+0

感謝您的信息。當下一個beta版本應該發佈? – Martin

相關問題