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

[Solved] how to change cell color without set Column's CellTemplate

3 Answers 125 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Weiqi
Top achievements
Rank 1
Weiqi asked on 18 Aug 2010, 05:33 AM
HI,

i created the columns programmingly due to the column name and binding path(same as the column name) is get from service.
below is the code. my question is i want to change the cell foreground using data binding. The problem is if i write a cell data template,
i can not write the binding path because the path is dynamical,  and saved in the variable columns.

 is there any want to slove this issue?

protected virtual void CreateColumns(object columns)
        {
            foreach (DataColumn column in (IList<DataColumn>)columns)
            {
                GridViewDataColumn dataColumn = new GridViewDataColumn();
                if (ColumnNameMap != null)
                {
                    dataColumn.Header = ColumnNameMap[column.ColumnName];
                    dataColumn.UniqueName = ColumnNameMap[column.ColumnName];
                }
                else
                {
                    dataColumn.Header = column.ColumnName;
                    dataColumn.UniqueName = column.ColumnName;
                }

                dataColumn.DataMemberBinding = new Binding("[" + column.ColumnName + "]" + ".StringValue");
                Columns.Add(dataColumn);
            }

        }

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 18 Aug 2010, 06:33 AM
Hi,

 Why not use CellStyleSelector instead?

Best wishes,
Vlad
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
G
Top achievements
Rank 1
answered on 24 Aug 2010, 04:23 PM
The example passes in the entire entity as opposed to just the property you want the converter to evaluate.

This is a bit of an issue if you want to use the cell template selector for multiple cells in a row.

How can you just pass the relevant Property into the converter?
0
Ryan
Top achievements
Rank 1
answered on 07 Jan 2011, 10:22 PM
It looks like this is applied to a column, so if you want different cell colors on the same row, you apply it to different columns. I'm about to find out.
Tags
GridView
Asked by
Weiqi
Top achievements
Rank 1
Answers by
Vlad
Telerik team
G
Top achievements
Rank 1
Ryan
Top achievements
Rank 1
Share this question
or