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

hide detailstable view

2 Answers 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ghadeer
Top achievements
Rank 1
ghadeer asked on 18 Nov 2008, 12:09 PM

 

Hi ALL,
I used radgrid with details view and I used DetailTableDataBind event to check  if the row in a master table have specific value ,I bind the details table if not,I want to make it invisible like:
protected
void rgStaffRequest_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)

 

{

 

 

string iCertificate = string.Empty;

 

string[] iTypes ={ };

 

 

 

try

 

 

 {

 

 

 

GridDataItem _dataItem = (GridDataItem)e.DetailTableView.ParentItem;

 

 

 

int _iRequestId = Convert.ToInt32(_dataItem["SRID"].Text);

 

 

 

switch (e.DetailTableView.Name)

 

 

 {

 

case "TravelPermitDetails":

 

 

 iCertificate = _dataItem[

 

 

"CERTIFICATE"].Text; // to check if the request for travel permit. 

 

iTypes = iCertificate.Split(','); 

 

 

 

foreach (string iType in iTypes)

 

 

 

if (iType.ToLower() == "Travel Permit".ToLower())

 

 

 {

e.DetailTableView.DataSource = _Controller.TravelDetails(_iRequestId);

 }
else
e.DetailTableView.visible=false;

 

break;

 

 

}

}

 

catch (Exception)

 

 

 {

throw;

 

 }
}



the problem that this code will hide the detailstable for all masetertable row!!!!!!!!
so how can I hide detalstable for some mastertable rows???????????

ghadeer

 

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 19 Nov 2008, 05:02 AM
Hello Ghadeer,

Try out the following code to hide the DetailTables for some rows in the MasterTableView.
cs:
protected void rgStaffRequest_PreRender(object sender, EventArgs e)  
    {           
        foreach (GridDataItem item in rgStaffRequest.MasterTableView.Items)  
        {  
 
 
            if (item.Expanded)  
            {  
                if (iType.ToLower() == "Travel Permit".ToLower()) 
                   { 
                          item.ChildItem.NestedTableViews[0].DataSource = _Controller.TravelDetails(_iRequestId);  
                   } 
                   else 
                    { 
                          item.ChildItem.NestedTableViews[0].Visible = false;  
 
                   } 
                 
            }  
        }  
    }  

Thanks
Princy.
0
ghadeer
Top achievements
Rank 1
answered on 19 Nov 2008, 05:27 AM
Hi there,
thanks in advance

I tries with this

 

protected void rgStaffRequest_PreRender(object sender, EventArgs e)

 

{

 

 

string iCertificate = string.Empty;

 

 

 

string[] iTypes ={ };

 

 

 

foreach (GridDataItem item in rgStaffRequest.MasterTableView.Items)

 

{

 

 

if (item.Expanded)

 

{

 

 

int _iRequestId = Convert.ToInt32(item["SRID"].Text);

 

iCertificate = item[

 

"CERTIFICATE"].Text; // to check if the request for travel permit.

 

 

iTypes = iCertificate.Split(

',');

 

 

 

foreach (string iType in iTypes)

 

 

 

if (iType.ToLower() == "Travel Permit".ToLower())

 

{

item.ChildItem.NestedTableViews[0].DataSource = _Controller.TravelDetails(_iRequestId);

}

 

 

else

 

 

item.ChildItem.NestedTableViews[0].Visible =

false;

 

 

 }

}


but it hide the detailtable for all master table row even it contain travelpermit value in certificate field?????????

 

Tags
Grid
Asked by
ghadeer
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
ghadeer
Top achievements
Rank 1
Share this question
or