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

Change # of columns in radgrid footer / footer template

3 Answers 404 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
ToltingColtAcres asked on 02 Dec 2015, 02:06 AM

I have a three-level master/detail radgrid (think: Bill of Materials application with "Item", "Assembly", "Part").

In the ItemDataBound event for the grid, I am capturing various metrics for each GridDataItem which I am then converting into a text value. The purpose is to give the operator some detailed information for each of the levels (e.g. "based on current inventory levels, we can only produce 5 of this assembly before Part ### is exhausted")

I have been attempting, without success, to customize the radgrid's footer for each level in order to display this information. Also in the itemDataBound event, the event item is a GridFooterItem, I attempt to customize the footer to display this information. I have attempted to do this a couple of ways, based on various forum postings.

One way that "works" is I change the text value of the first column (column #2, as column #0 = expand Column and column #1 = rowindicator column in the grid). I also set the columnspan value to reflect the total # of columns less 2 (for #'s 0 & 1). E.g.:

footeritem["column2"].ColumnSpan = 8;
footeritem["column2"].Text = my-String-field;

 

I say this works, because, it does "work" (e.g. the data is displayed correctly for the footer), except, it "breaks" the layout of the grid in such a way that each of the levels' columns are no longer fully justified to the left and right sides of the grid. What I end up with is a grid where each detail level's data is displayed as "ragged right". It appears what happens is each column, at each level, in the grid is set to the absolute minimum amount of space needed to display the value.

Removing the ColumnSpan directive results in the grid being laid out properly (e.g. all columns dynamically sized to make the grid at all 3 levels fully justified to the right and left.) However, since column#2 might be only, say, 100 pixels, I end up with 5-10 "lines" of wrapped text containing my string field, which is not very professional looking.

 

Question: Is there a way to create a custom footer template for the radgrid with a single "column" which will be laid out correctly; that is, I could have a single column which spans the entire width of the radgrid so I can populate it with my text value, and not "break" the full justification of the grid?

3 Answers, 1 is accepted

Sort by
0
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
answered on 02 Dec 2015, 02:30 PM
A couple of followup pics... The first picture shows the effect of adding the "ColumnSpan" parameter, which does allow my text to span multiple columns in the footer, but then messes up the formatting of the grid on the right.

The 2nd shows how everything is nicely formatted when not using ColumnSpan, but, I'd like to be able to get the text shown in the 3rd picture to span across the entire row as if all the columns were spanned together. 

Any assistance on how I can accomplish this would be appreciated.
0
Konstantin Dikov
Telerik team
answered on 04 Dec 2015, 02:48 PM
Hello,

You need to ensure that you are setting the correct ColSpan to the TableCell and that you are preventing the other cells from rendering:
int colCount = 0;
foreach (GridColumn column in filterItem.OwnerTableView.RenderColumns)
{
    if (column.UniqueName != "ExpandColumn" && column.UniqueName != "RowIndicatorColumn")
    {
        TableCell cell = filterItem[column.UniqueName];
        colCount++;
        cell.Visible = false;
    }  
}
 
filterItem["column2"].ColumnSpan = colCount;
filterItem["column2"].Text = "test";
filterItem["column2"].Visible = true;

Hope this helps.


Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
answered on 06 Dec 2015, 04:29 PM

I found setting visibility on the cells only resulted in me getting the "jagged right" output rather than the fully-justified output which makes the grid look like and professional.

Based on some other posts I found on the 'net, I did this, which worked:

GridFooterItem fitem = (GridFooterItem)e.Item;
fitem["Cell2"].Text = mytestmessage;
fitem["Cell10"].Text =  anothertestmessage;
fitem.Cells.RemoveAt(9);
fitem.Cells.RemoveAt(8);
fitem.Cells.RemoveAt(7);
fitem.Cells.RemoveAt(6);
fitem.Cells.RemoveAt(5);
fitem.Cells.RemoveAt(4);
fitem.Cells.RemoveAt(3);
fitem.Cells[2].ColumnSpan = 8;

Tags
Grid
Asked by
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
Answers by
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
Konstantin Dikov
Telerik team
Share this question
or