We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Custom

A GridDataControl is bound to an ObservableDataCollection. No columns are defined in xaml.

Data looks like:
Book ABC DEF
Price 1.2345 1.4567
Change .03 .04

So the price is a decimal which should be formatted one way and the 'change' is a percent which should be formatted a different way. A column would contain multiple types.

What would be an easy way to do this?

I would like to make them custom types MyDecimal and MyPercent. Then create 2 IValueConverters.

If common is my namespace, converters are declared in xaml:



What is the xaml to the converters to the types in a GridDataControl? A full xaml file is attached.








sample_5e31e2a4.zip

5 Replies

SP Soundara Pandian S Syncfusion Team March 22, 2012 11:21 AM UTC

Hi Andrew,

We have analyzed your requirements and this can done by using ValueConverter property in VisibleColumn. Also we have prepared a sample based on this and please find the sample under the following location.

Thanks,
Soundara Pandian S




WpfApplication1_86b599fc.zip


AR Andrew Rosenblum March 22, 2012 08:45 PM UTC

Can DataTemplates be set in the xaml without defining Visible Columns in the xaml?

In the attached code, the xaml file defines Visible Columns.

In the thread DataTemplateSelector, the c# delegate sets the data template:
private static void ModelQueryCellInfo(object sender_, GridQueryCellInfoEventArgs e_)
{
if (e_.Style.CellValue is IDecimalNumber)
{
e_.Style.CellType = "DataBoundTemplate";
e_.Style.CellItemTemplateKey = e_.Style.CellValue.GetType().Name + "Template";
}
}

The delegate would set a cell with an object of type NoDecimalNumber (which extends IDecimalNumber) to the NoDecimalNumberTemplate.

Can NoDecimalNumber be assigned to NoDecimalNumberTemplate in xaml?




SP Soundara Pandian S Syncfusion Team March 23, 2012 10:42 AM UTC

Hi Andrew,

We have analyzed your requirements and this can done by using ItemTemplate. Also we have prepared a sample based on this and please find the sample under the following location.

Please let us know if you have any queries.


Thanks,
Soundara Pandian S




DataTempSelector_4d738f91.zip


AR Andrew Rosenblum March 26, 2012 03:39 PM UTC

Can the DataTemplate be assigned in xaml? We don't want to use code like the QueryCellInfo delegate.



SN Sankara Narayanan N Syncfusion Team April 4, 2012 12:54 PM UTC

Hi Andrew,

It is not possible to set the DataTemplate in XAML when VisibleColumns are not in XAML. DataTemplates can be assigned specific to columns only and not to Grid.

Please let us know if you have any questions.

Thanks,
Sankar


Loader.
Live Chat Icon For mobile
Up arrow icon