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
105
Span cell across a row
posted

hi,

im looking for a way to span a cell across a row, but only for some rows not for all the rows in the grid

(like creating an unbound column and hiding the columns i want to merge, this will make it for all the rows)

i created a table below witch show a grid with 4 columns, and between some rows in the table

i would like to put a row with only one cell "some single cell row" like in this example

column value 1   |   column value 2   |   column value 3   |   column value 4
some single cell row
some single cell row
some single cell row
column value 1   |   column value 2   |   column value 3   |   column value 4
column value 1   |   column value 2   |   column value 3   |   column value 4
some single cell row
some single cell row
some single cell row
some single cell row
column value 1   |   column value 2   |   column value 3   |   column value 4
column value 1   |   column value 2   |   column value 3   |   column value 4
some single cell row
some single cell row

 

let say i got 4 columns on my grid so

what i tried  to do is to use RowLayout and add an extra column to the grid putting the origenX = 0, origenY = 2 to it

and the spanX = 8 spanY = 2 and it put for each row a single cell spaning from one side to another

my problem with that is that i cant hide the cells when i dont need them, since i want to display for each row either the original 4 columns

or the new cell not all of them together

 

here is my code, if the cell.hide = true whould hide the cell completly it would achive my goal is there a way to do it

or another way to do what i need

private void grdPreview_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)

{

// Clear the current unbound columns

e.Layout.Bands[0].Columns.ClearUnbound();

// Get the header line

string headerLine = previewFile.PreviewLines[previewFile.HeaderIndex];

string[ headers = headerLine.Split(',');

int index = 0;foreach (string header in headers)

{

// Create the column for the header

UltraGridColumn column = e.Layout.Bands[0].Columns.Add("column" + (index + 1).ToString());

column.Header.Caption = header;

column.RowLayoutColumnInfo.OriginX = index * 2;

column.RowLayoutColumnInfo.OriginY = 0;

column.RowLayoutColumnInfo.SpanX = 2;

column.RowLayoutColumnInfo.SpanY = 2;

index++;

}

// Create the data column

UltraGridColumn data = e.Layout.Bands[0].Columns[0];

data.RowLayoutColumnInfo.OriginX = 0;

data.RowLayoutColumnInfo.OriginY = 2;

data.RowLayoutColumnInfo.SpanX = previewFile.NumberOfColumns * 2;

data.RowLayoutColumnInfo.SpanY = 2;

// Hide the columns headers

e.Layout.Bands[0].HeaderVisible = false;

e.Layout.Bands[0].ColHeadersVisible = false;

e.Layout.Bands[0].UseRowLayout = true;

}

private void grdPreview_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)

{

if (e.Row.Index < previewFile.HeaderIndex ||

(e.Row.Index > previewFile.HeaderIndex && e.Row.Index < previewFile.DataStartIndex))

{

// Hide the rest of the cells

for (int index = 0; index < previewFile.NumberOfColumns; index++)e.Row.Cells["column" + (index + 1).ToString()].Hidden = true;

}

else

{

// Get the line data

string line = e.Row.Cells[0].Value.ToString();

string[ headers = line.Split(',');

e.Row.Cells[0].Hidden = true;

// set the columns data

for (int index = 0; index < previewFile.NumberOfColumns; index++)e.Row.Cells["column" + (index + 1).ToString()].Value = headers[index];

}

}

 

 

 

Parents Reply Children
No Data