2011-02-10 10 views
1

UltraGridにはマスター/詳細関係があります。また、ユーザーが行をクリックすると、新しいUltraGridに子行を表示したい。どのようにできるのか?ありがとうUltraGridから子行を取得

答えて

1

最初のグリッドのAfterRowActivateイベントまたはAfterRowSelectedイベントを処理し、2番目のグリッドに適切なデータを設定することができます。 あなたが第2のグリッド内のすべての親行のデータを持っている場合もapropriatlyこのような列フィルタを設定することができます:あなたはColumnFiltersを使用している場合

private void ugParent_AfterRowActivate(object sender, EventArgs e) 
{ 
    if (this.ugParent.ActiveRow != null) 
    { 
    //either populate the grid with data specific to the current row: 
    //this.ugChilds.DataSource = this.GetChildData(this.ugParent.ActiveRow); 
    //or filter the grid 
    object key = this.ugParent.ActiveRow.Cells["IDField"].Value; 
    this.ugChilds.DisplayLayout.Bands[0].ColumnFilters["RelationField"].FilterConditions.Add(FilterComparisionOperator.Equals, key); 
    } 
    else 
    { 
    //clear Child grid if required. If you set datasource to null you will loose all layout and need to relayout the grid on next binding 
    } 
} 

は、既存のフィルタを再利用するか、前に新しいフィルタを追加するフィルタ条件をクリアすることを忘れないでください条件。

関連する問題