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

Change the template depending to the value of the column

0 Answers 28 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sébastien
Top achievements
Rank 1
Sébastien asked on 18 Oct 2010, 01:55 PM
Hello,
I use the Grid to display datas, some of them are "boolean". i would like to display an "OK" icon only if the value of the column is "TRUE". If it is "FALSE", i don' t display anything. How can I do that ?
.....
.....
.Columns(c =>
{
c.Bound("My boolean property")
.ClientTemplate(/* an image if is it TRUE, nothing if FALSE */)
}
 
Here is a first test
private string GetItem<T>(string propertyName)
{

   Type t = /* Here is the type of my property (external method);  */
 
// if bool, display an image only if the value is TRUE
if (t == typeof(bool))
{
       // TODO : display an image only if TRUE, nothing if FALSE
       if(*/myValue*/)
             {
// mHelper is HtlmHelper type
                return mHelper.Image(/Images/true.png");
            }
 
          // if not, display the value of the property
            return string.Format("<#={0}#>", propertyName);
        }

But it always displays an image, because I can't have the value of the property name, only the type...

Thanks !!
Tags
Grid
Asked by
Sébastien
Top achievements
Rank 1
Share this question
or