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
1965
Setting the width of child grid
posted

Hey,

I have this event for binding child grid to the row which is clicked to expand.

void whdgData_RowIslandsPopulating(object sender, ContainerRowCancelEventArgs e)
{
e.Cancel = true;

int ID = Convert.ToInt32(e.Row.DataKey[0]);
DataView dvTest = new DataView(dsData.Tables["Details"], "ID ="+ID, "", DataViewRowState.CurrentRows);

ContainerGrid childGrid = new ContainerGrid();
e.Row.RowIslands.Add(childGrid);

childGrid.DataSource = dvTest.ToTable();
childGrid.DataBind();
//childGrid.Columns[2].Width = 100;
//childGrid.Columns[2].Header.Text = "Date";
}

I have to format the grid header and widths of the child grid. Please help with that.

I have tried e.Row.RowIslands[0].Columns.count but it is 0. Somebody please help on setting the width and header text for this container grid.

Thanks and Regards,

Parthiban Sekar

  • 29417
    Offline posted

    Hello Parthiban, 

    I’m just following up to see if you’ve been able to resolve your issue. If you have any questions or concerns or if you need further assistance please let me know.

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer

    Infragistics, Inc.

    http://es.infragistics.com/support

     

  • 29417
    Offline posted

    Hello Parthiban,

     Thank you for posting in our forum.

    When the container grid is created it has the default settings for the grid. So it has AutoGenerateColumns is set to true by default. When that’s set to true the grid generated the columns based on the data source ,however they’re not added to the Columns collection so it will remain empty. You could set that property to false and manually create the columns with the settings you want and add them to the container grid’s columns collection. For example:  

    IslandGrid.AutoGenerateColumns = false;       
            if (IslandGrid.Columns.Count == 0)
            {
                BoundDataField field1 = new BoundDataField();
                field1.DataFieldName = "id";
                field1.Key = "id";
                field1.Width = Unit.Pixel(200);
                field1.Header.Text = "id";

                BoundDataField field2 = new BoundDataField();
                field2.Key = "Item";
                field2.DataFieldName = "Item";
                field2.Width = Unit.Pixel(200);
                field2.Header.Text = "Item";

                BoundDataField field3 = new BoundDataField();
                field3.Key = "Data";
                field3.DataFieldName = "Data";
                field3.Width = Unit.Pixel(200);
                field3.Header.Text = "Data";


             

                IslandGrid.Columns.Add(field1);
                IslandGrid.Columns.Add(field2);
                IslandGrid.Columns.Add(field3);
              
            }

     

    Please refer to the attached sample that demonstrated this and let me know if you have any questions.

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer II

    Infragistics, Inc.

    http://es.infragistics.com/support

     

    WHDG_ManualLoad.zip