<Grid>
<TextBlock Text="{Binding Converter={StaticResource CellConverter}}" />
</Grid>
Hi Nicky,
Thanks
for contacting Syncfusion support.
Please
find the response for your queries below,
Query
1:
We
have analyzed your query. We found that the issue has occured because of
defining the binding without “Path” value. By setting the column mapping name
as binding path you can get the corresponding cell value in the converter.
Query
2:
We
have provided new features like DisplayBinding and ValueBinding in GridColumn
to enhance data formatting in a column.
DisplayBinding : Sets the binding
for GridColumns when the gridcell is in view mode.
ValueBinding : Sets the binding
for GridColumns when the gridcell is in edit mode.
Intead
of using GridTemplateColumns you can use the DisplayBinding and ValueBinding
for data formatting. By default DataGrid performs sorting, filtering and
grouping using reflection based on the column MappingName. Hence you must
define the MappingName for the column. However DataGrid allows you to perform
sorting,filtering and grouping based on ValueBinding by setting “UseBindingValues”
property as true.
We
have created the simple sample with Dynamic objects to demonstrate the
DisplayBinding and ValueBinding. Please check the sample under the following
location,
Sample: http://www.syncfusion.com/downloads/Support/DirectTrac/109421/SampleTest-250128632.zip
Note: In the above sample
DisplayBinding and ValueBinding applied for "Price" column.
Please
let us know if you have any queries.
Regards,
Riyaj
Ahamed I
Hi Nicky,
Thanks for your update and sorry for the
inconvenience caused.
Query 1:
We have analysed the reported issue
(problem with the converter when using DataTemplates) with our sample. If you
are unable to set MappingName for the column then set unique key as MappingName
for that column and pass that unique key as converter parameter. So that you
can able to get the value based on that unique key.
To apply sorting, filtering and grouping
for that column use the same binding value for DisplayBinding and ValueBinding.
And also you have to set UseBindingValue as true.
We have created simple sample with
GridTemplateColumn and please check the sample under the following location,
Sample:
CustomSample.zip
Query 2:
We suspect that you might have used
NavigationMode as Row in your application. Please set NavigationMode as Cell to
make cell as clickable. By wire up “CurrentCellActivated” event of DataGrid you can get
the information about which cell was clicked.
Please let us know if you have any
concerns.
Thank you,
Dineshprabhu V
Hi Nicky,
Thanks for your update.
We have analyzed your sample. We found that you are using Single
DataTemplate for all the columns and the DataTemplate contains Binding without
Path value. Hence you got the whole row DataContext as value in Converter. To
overcome the issue you must define individual DataTemplate for every columns
and set the path or converter parameter value in Binding.
Please let us know if you have any concern.
Regards,
Riyaj Ahamed I
Hi Nicky,
Thanks for your update.
We have analyzed your sample. We found that you are using Single
DataTemplate for all the columns and the DataTemplate contains Binding without
Path value. Hence you got the whole row DataContext as value in Converter. To
overcome the issue you must define individual DataTemplate for every columns
and set the path or converter parameter value in Binding.
Please let us know if you have any concern.
Regards,
Riyaj Ahamed I
Hi Nicky,
In DataGrid by default we are setting the whole row data as
DataContext for the GridCells. To display particular column value along with
some other column value in data template and to format the cell based on
another column value for this scenarios we need the whole row data as
DataContext.
You can override this behavior by writing the custom cell
renderer to the data template cells. We have created the sample with custom
Data template renderer to set the data
context based on the mapping name. please find the sample in the following
location
Sample: DataGridWithCustomRenderer.zip
And in the GridTemplateColumn we are using DisplayBinding
and ValueBinding values for Sorting, Filtering and Grouping operations.
Regards,
Riyaj Ahamed I
Hi Nicky,
Thanks for
your update.
Please let
us know if you need further assistance.
Regards,
Riyaj Ahamed
I
<Grid>
<TextBlock Text="{Binding, Converter={StaticResource NumericConverter}}" />
</Grid>
Hi Nicky,
Thanks for your update.
We have analyzed your query. We would like to let you know
that this issue was fixed in our latest version v11.2.0.29 which is available
for download in following location,
Link:
We have updated the custom template cell renderer to
overcome this issue and please check the sample under the following location,
Sample:
Please let us know if you need further assistance.
Thank you,
Jai Ganesh S
Hi Nicky,
We Couldn’t get your requirement clearly. Please share some more information which will be help us to provide better solution earlier.
Please let us know if you have any queries.
Regards,
Akila
Hi
As you can
see in my sample, my application uses a custom renderer for templated columns
when using the SfDataGrid. The reason for this is a far as I understand, that
my datasource is an object, which contains a collection of objects. My
dataobjects are very dynamic, and I cannot change this model. Then I contacted
you people in this thread, more precisely on June 26 2013, Riyaj Ahamed posted
a sample containing this custom renderer. This have worked fine for some time,
but now it struggles, and I don’t have access to re-download the provided
sample posted in this thread anymore, so I honestly don’t know if I’m missing
anything.
Anyways,
the problem occurs when my search method returns a collection with less rows
than the pagesize. As you can see in the sample, if you type “Nicky” in the
textbox in the top of the screen, there are some rows where just the firstname
is shown. Those rows does not exists. There is exactly 16 rows in the
datasource with the firstname Nicky, and all of them has the lastname Mogensen.
The first
column is a templated column, which uses the custom renderer provided almost a
year ago. The second one is a basic TextColumn, and that one works just fine –
it does not show anything on the empty rows just as it should.
This means,
that there must have been an update to the SfDataGrid, which is causing the
custom renderer to fail. It leaves the values hanging, instead of showing an
empty cell when there is not enough rows.
That is why
I’m trying to get some help, getting this to work again. It has been working,
but it seems broken now. In the sample provided, I have taken the DataTable
usercontrol from my solution and trimmed down all unnecessary code to replicate
the problem, and modified for demo purposes of course.
In
DataTable.xaml.cs on lines 167-212 is the method that performs the search and
sets the data.
In
DataTable.xaml.cs on lines 107-127 is the method that creates the grid columns,
where you will see that I replace the renderer for templated columns with the
custom one provided in this thread, and I create an StringColumn, which is a
custom call that inherits from GridTemplatedColumn which is defined on lines
284-293.
The custom
renderer is in the file CustomCellGridTemplateRenderer.cs, where I kind a seem to
remember that I have corrected a bug. However, as I said earlier; I cannot
download the provided sample, to see what I have changed and see if that is the
cause of the error.
Hope this
clarifies it a little bit.
Best
Regards
Nicky
Hi Nicky,
In previous version, if DataContext is null then InitializeDisplayElement method
in renderer will not be called. But in current version, InitializeDisplayElement
method will be called and as we are reusing the rows, we have to set the value
based on DataContext. In the customer cell renderer, value is not reset if the
DataContext is null. Now we have modified the sample to resolve this issue,
Please refer the following
modified sample
Sample: DataGridTest2Modified.zip
Please let us know if you have any
queries.
Regards,
Sivakumar