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

binding due to condition

3 Answers 72 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.
Nebras
Top achievements
Rank 1
Nebras asked on 23 Mar 2011, 01:00 PM
I want to bind a column depending on a condition i did
 columns.Bound(p =>
                                {
                                    if (Helper.Language.StartsWith("en"))
                                    {
                                       p.Patient.FirstNameEnglish;
                                    }
                                    else
                                    {
                                     p.Patient.FirstName;
                                    }
                                })

but it gives this error "Cannot convert lambda expression to type 'string' because it is not a delegate type"

3 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 23 Mar 2011, 02:02 PM
Hello Nebras ,

 Of course this is not supported as the grid needs a simple member expression (field or property access). This should work:

if (Helper.Language.StartsWith("en"))
{
   columns.Bound(p => p.Patient.FirstNameEnglish);
}
else
{
   columns.Bound(p => p.Patient.FirstName);
}

Greetings,
Atanas Korchev
the Telerik team
0
Nebras
Top achievements
Rank 1
answered on 23 Mar 2011, 03:37 PM
Thanks Atanas , it works ..
0
Linard
Top achievements
Rank 1
answered on 24 Mar 2011, 06:16 PM
Hi there

Is there a solution for a scenario like:

if (Helper.Language.StartsWith("en"))
{
   columns.Bound(p => p.Patient.FirstNameEnglish).Visible(p.IsVisible);
}
else
{
   columns.Bound(p => p.Patient.FirstName).Visible(p.IsVisible);
}

a very poor example, that cannot work of course, but how could the Visible(bool) method be controlled by the actual data object?

Thanks,
 Linard
Tags
Grid
Asked by
Nebras
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Nebras
Top achievements
Rank 1
Linard
Top achievements
Rank 1
Share this question
or