Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
400
WebHierarchicalDataGrid
posted

Hello,

I am having 2 problems with the WHDG right now. 

1.  I am trying to define the columns and child columns in c# code at runtime.  My data source is a LINQ object with the following structure:

public string PartNo { get; set; }
public string PartDesc { get; set; }
public string CustomerPartNo { get; set; }
public int TotalQty { get; set; }
public List<ConsignmentCase> Cases  //this contains the child rows

The Cases object looks like this:

public int ID { get; set; }
public string PartNo { get; set; }
public string CaseNo { get; set; }
public DateTime MfgDate { get; set; }
public DateTime ExpDate {get;set;}
public int Qty { get; set; }
public string CustomerPO { get; set; }

I have set AutogenerateColumns and AutoGenerateBands to false

//Here's the markup

<ig:WebHierarchicalDataGrid ID="InventoryGrid" InitialDataBindDepth="1" MaxDataBindDepth="1" DataKeyFields="PartNo" runat="server" Width="100%" OnInitializeRow="InventoryGrid_InitializeRow" AutoGenerateColumns="false" AutoGenerateBands="false" ExpandButton-ImageUrl="~/ig_res/Default/images/expand.gif" ExpandButton-PressedImageUrl="~/ig_res/Default/images/expand_hover.gif" ExpandButton-HoverImageUrl="~/ig_res/Default/images/expand_hover.gif" CollapseButton-ImageUrl="~/ig_res/Default/images/collapse.gif" CollapseButton-HoverImageUrl="~/ig_res/Default/images/collapse_hover.gif" CollapseButton-PressedImageUrl="~/ig_res/Default/images/collapse_hover.gif">
</ig:WebHierarchicalDataGrid>

//Here's the code to build the grid columns

InventoryGrid.Columns.Clear();
InventoryGrid.GridView.Columns.Clear();
InventoryGrid.GridView.ClearDataSource();
InventoryGrid.Visible = true;

InventoryGrid.DataSource = ftsRepository.GetConsignmentInventory(OverrideCompany, txtSearch.Text);

//manually add the columns to the parent level of the hierarchy;
// allows us to set the Column Header and width
BoundDataField bdf = new BoundDataField();
bdf.DataFieldName = "PartNo";
bdf.Key = "PartNo";
bdf.Header.Text = "Part No.";
bdf.Width = 186;
InventoryGrid.GridView.Columns.Add(bdf);

bdf = new BoundDataField();
bdf.DataFieldName = "CustomerPartNo";
bdf.Key = "CustomerPartNo";
bdf.Header.Text = "Customer Part No.";
bdf.Width = 186;
InventoryGrid.GridView.Columns.Add(bdf);

bdf = new BoundDataField();
bdf.DataFieldName = "TotalQty";
bdf.Key = "TotalQty";
bdf.Header.Text = "Quantity";
bdf.Width = 90;
InventoryGrid.GridView.Columns.Add(bdf);

bdf = new BoundDataField();
bdf.DataFieldName = "PartDesc";
bdf.Key = "PartDesc";
bdf.Header.Text = "Part Description";
bdf.Width = 336;
InventoryGrid.GridView.Columns.Add(bdf);

Band childBand = new Band();
childBand.DataKeyFields = "CaseNo";
childBand.DataMember = "Cases";

childBand.Key = "CaseNo";
InventoryGrid.Bands.Add(childBand);

UnboundCheckBoxField cbf = new UnboundCheckBoxField();
cbf.Key = "ID";
cbf.Width = 25;
InventoryGrid.Bands[0].Columns.Add(cbf);

bdf = new BoundDataField();

bdf.Key = "PartNo";

bdf.Header.Text = "Part No";
InventoryGrid.Bands[0].Columns.Add(bdf);

bdf = new BoundDataField();
bdf.Key = "CaseNo";
bdf.Header.Text = "Case No";
InventoryGrid.Bands[0].Columns.Add(bdf);

Event though Autogeneratebands is false, the columns in my child Cases all appear in the child grid, in addition to the 2 child columns i have added.  How can I get this to only include the columns that I am specifically adding?

2. When I try to add a Unboundcheckbox field to the Child grid, the checkbox is not editable.  How can I enable the checkbox in my c# code?

Thank you,

Steve

Parents Reply Children
No Data