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

filter the child rows

0 Answers 39 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Orit
Top achievements
Rank 1
Orit asked on 08 Sep 2009, 09:19 AM
I arranged my "things to do"
and now I need tow things
1. have the ability to filter the child rows
2.  have the ability to filter the items in the ComboBoxColumn of the child grid

I think to do it in the OnChildGridLoaded
when I get to it the value in the ((RadGridView)sender).ItemsSource
is {System.Linq.Enumerable.WhereEnumerableIterator<System.Data.DataRow>}

how can I filter it? or is there another way to filter


 

private void BindDataMainGrid()  
        {  
            try  
            {  
                thisthis.gvAccount.ItemsSource = this.GetData();              
            }  
            catch{}  
        }  
 
        private DataSet GetData()  
        {  
            try  
            {  
                dsb = ServiceData.GetBudgetsByOBS(iOBSID);  
                if (dsb != null)  
                {  
                    dsb.Tables["Budget"].Columns.Add("SumBudgetAllocation", typeof(float));  
                    dsb.Tables["Budget"].Columns.Add("SumBudgetRequest", typeof(float));  
                    dsb.Tables["Budget"].Columns.Add("SumOrderAllocation", typeof(float));  
                    dsb.Tables["Budget"].Columns.Add("SumOrderPaid", typeof(float));  
                   
                    foreach (DataRow dr in dsb.Tables["Budget"].Rows)  
                    {  
                        dr["RowStatus"] = 0;  
                        if (dsb.Tables["BudgetAllocation"].Select("id=" + Convert.ToInt32(dr["ID"])).GetLength(0) > 0)  
                        {  
                            dr["SumBudgetAllocation"] = Convert.ToDecimal(((LM_Model.dsBudget.BudgetAllocationRow)dsb.Tables["BudgetAllocation"].Select("id=" + Convert.ToInt32(dr["ID"]))[0]).ItemArray[1]);  
                        }  
                        if (dsb.Tables["BudgetRequest"].Select("BudgetId=" + Convert.ToInt32(dr["ID"])).GetLength(0) > 0)  
                        {  
                            dr["SumBudgetRequest"] = Convert.ToDecimal(((LM_Model.dsBudget.BudgetRequestRow)dsb.Tables["BudgetRequest"].Select("BudgetId=" + Convert.ToInt32(dr["ID"]))[0]).ItemArray[1]);  
                        }  
                        if (dsb.Tables["BudgetOrder"].Select("BudgetId=" + Convert.ToInt32(dr["ID"])).GetLength(0) > 0)  
                        {  
                            dr["SumOrderAllocation"] = Convert.ToDecimal(((LM_Model.dsBudget.BudgetOrderRow)dsb.Tables["BudgetOrder"].Select("BudgetId=" + Convert.ToInt32(dr["ID"]))[0]).ItemArray[1]);  
                        }  
                        if (dsb.Tables["BudgetOrderPaid"].Select("Id=" + Convert.ToInt32(dr["ID"])).GetLength(0) > 0)  
                        {  
                            dr["SumOrderPaid"] = Convert.ToDecimal(((LM_Model.dsBudget.BudgetOrderPaidRow)dsb.Tables["BudgetOrderPaid"].Select("Id=" + Convert.ToInt32(dr["ID"]))[0]).ItemArray[1]);  
                        }  
                    }  
                     
                    dsb.Tables["Budget"].Columns.Add("BalanceBudgetAllocation", typeof(float), "TotalBudget-SumBudgetAllocation");  
                    dsb.Tables["Budget"].Columns.Add("BalanceToPay", typeof(float), "SumBudgetRequest-SumOrderPaid");  
                      
                    //Build dsAcoount  
                    dsAcoount = new DataSet();  
                    DataView dv = new DataView(dsb.Tables["Budget"], "Type=1", "", DataViewRowState.CurrentRows);  
                    dsAcoount.Tables.Add((DataTable)dv.ToTable("Account"));  
                    dv = new DataView(dsb.Tables["Budget"], "Type=2", "", DataViewRowState.CurrentRows);  
                    dsAcoount.Tables.Add((DataTable)dv.ToTable("Budget"));  
                    dv = new DataView(dsb.Tables["Budget"], "Type=3", "", DataViewRowState.CurrentRows);  
                    dsAcoount.Tables.Add((DataTable)dv.ToTable("SubBudget"));  
                                    
                    LM_Model.clsEnums.BudgetType eVal = clsEnums.BudgetType.Investment;  
                    decimal dCurrentInvestment = Convert.ToDecimal(dsAcoount.Tables["Account"].Compute("SUM(TotalBudget)", "BudgetType=" + Convert.ToInt32(eVal)));  
                    txtbInvestmentSum.Text = dCurrentInvestment.ToString("#,##0.00");  
                    eVal = clsEnums.BudgetType.Continuous;  
                    decimal dCurrentContinues = Convert.ToDecimal(dsAcoount.Tables["Account"].Compute("SUM(TotalBudget)", "BudgetType=" + Convert.ToInt32(eVal)));  
                    txtbContinuesSum.Text = dCurrentContinues.ToString("#,##0.00");  
 
                    decimal dInvestmentBaseline = Convert.ToDecimal(dsb.Tables["BaselineBudget"].Rows[0]["InvestmentBaseline"]);  
                    decimal dContinuesBaseline = Convert.ToDecimal(dsb.Tables["BaselineBudget"].Rows[0]["ContinuesBaseline"]);  
 
                    decimal dI = (dCurrentInvestment / dInvestmentBaseline - 1) * 100;  
                    decimal dC = (dCurrentContinues / dContinuesBaseline - 1) * 100;  
 
                    txtInv.Text = dI.ToString("#.00");  
                    txtCon.Text = dC.ToString("#.00");  
 
                    DateTime dDate = (DateTime)dsb.Tables["BaselineBudget"].Rows[0]["Date"];  
                    txtBLDate.Text = dDate.ToString("dd/MM/yyyy");  
 
                    //Add Relations  
                    dsAcoount.Relations.Add("BudgetRelation",  
                    dsAcoount.Tables["Account"].Columns["Number"],  
                    dsAcoount.Tables["Budget"].Columns["ParentID"]);  
                      
                    dsAcoount.Relations.Add("SubBudgetRelation",  
                    dsAcoount.Tables["Budget"].Columns["Number"],  
                    dsAcoount.Tables["SubBudget"].Columns["ParentID"]);  
                      
                    return dsAcoount;  
                }  
            }  
            catch { }  
            return null;  
        }  
 

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Orit
Top achievements
Rank 1
Share this question
or