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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom

Thread ID:

Created:

Updated:

Platform:

Replies:

102956 Mar 16,2012 09:35 PM UTC Apr 4,2012 12:54 PM UTC WPF 5
loading
Tags: GridControl
Andrew Rosenblum
Asked On March 16, 2012 09:35 PM UTC

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

Soundara Pandian S [Syncfusion]
Replied On 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

Andrew Rosenblum
Replied On 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?



Soundara Pandian S [Syncfusion]
Replied On 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

Andrew Rosenblum
Replied On 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.


Sankara Narayanan N [Syncfusion]
Replied On 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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;