This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I've noticed that if I specify a DisplayTemplate on a column and a DisplayMemberBinding, then the DisplayTemplate gets ignored. If I don't provide the DisplayMemberBinding, then I get an exception when I try to sort or group by that column. I would imagine that I could write an IComparer (set the SortComparer rather than the DisplayMemberBinding)that would solve the issue, but I'd rather specify the binding than write several comparison methods. I was hoping that the DisplayTemplate would be used to display the cell contents, but use the DisplayMemberBinding for sorting/grouping. |
|
|
Hello Jared Thanks for this great feedback. The next nightly build will allow DisplayTemplate and DisplayMemberBindings to work on the same column as you have described. Jason Fauchelle |
|
|
Thanks Jason! That seems to work well. |
|
|
Thanks Jason! That seems to work well. |
|
|
I did run into an issue, I'm not sure if it is related to this change, but now I'm experiencing issues with the DisplayMemberBinding. If the mode is set to TwoWay, then the cell is no longer editable. Also, the StringFormat property doesn't seem be getting applied. Could you look into this please? If you need more information or help please let me know. Thanks. |
|
|
Hello Jared DisplayMemberBinding will support StringFormat in the next nightly build. I have not been able to reproduce your other issue. When I set the mode to TwoWay the cells are editable. If you could send code snippets of the property you are binding to and the xaml code for the DataGridColumn then I'll try reproduce this again. Jason Fauchelle |
|
|
Jason, thanks for fixing the StringFormat issue. I think I've figured out what is causing the other issue. I'm binding to a Nullable type (i.e. int? or double?). When debugging, inside BuiltInEditor.cs there is a method called GetEditorKey(Node node, bool editable, out bool allowExpand). At the bottom of that method, it checks for text editable types and returns a simple text editor. Is there any way nullable types could be added to use the simple text editor? Is there a better way? Do I need to provide my own editor for these types? Would it be reasonable to convert text based on string.IsNullOrWhitespace(text) to null otherwise do the typical double.TryParse or int.TryParse etc.?
Thanks! |
|
|
Hello Jared Thanks for this feedback and finding the cause of this issue. The next nightly build will have support for editing nullable value types such as int? and double?. You will not need to provide custom editors for these types. Nullable value types will be assigned the simple text editor. If there is nothing typed into this editor (empty string), it will set the property value to be null. Jason Fauchelle |
|
|
Thanks for handling the nullable value types. That works well. I did notice one other issue related to the string format. The string format does not seem to get applied to the edit control. For example, see the binding below:
Let's say for a particular item the DoubleValue is .913. When the cell is rendered (display template) it is displayed as 91.3 %. Perfect! But, when you edit that cell, the value displayed in the edit control is 0.913. I was hoping to see 91.3 %. Now there may be a problem with that because you would have to "undo" the string format (remove percentage symbol and move decimal two places) to convert the data in order to call the setter. Let me know what you think ought to happen here. I would imagine that this is a fairly common scenario (cost, percentages, etc.). |
|
|
Hello Jared Unfortunately I have not been able to find a way for the StringFormat to be used in the editor template. For now you'll need to create a custom EditorTemplate for these columns. Note that you can use our CurrencyTextBox and PercentageTextBox controls within the EditorTemplate to help you out here. These support "undoing" the string format as you described. Sorry for the inconvenience here. I've noted down this functionality as a future enhancement. Jason Fauchelle |
|
|
One other thing that I've run into using the DisplayMemberBinding...if I set NotifyOnSourceUpdated=True, I'm not getting Binding.SourceUpdated events fired.
Yet, if I use it when I supply my own EditorTemplate, then I do get Binding.SourceUpdated events.
Thanks. |
|
|
Hello Jared I'll look into this early next week. Jason Fauchelle |
|
|
Hello Jared The reason why this does not work is because the DisplayMemberBinding is actually attached to an adapter mechanism which is used to hook into the core DataGrid logic such as selecting the appropriate editor for the data type. The adapter is not part of the visual tree which is why you haven't been able to catch the event. Unfortunately I have not yet been able to find a good way for this to work. Are you able to go without this event such as listening to the source changes from the model objects? If not, you'll need to resort to setting the EditorTemplate like you mentioned. I hope you wouldn't need to do this on too many columns. I have noted this down as a future enhancement. Jason Fauchelle |
|
|
Thanks for the feedback. I am able to listen to the source changes from the model objects, and so that's the route I've pursued. In my current scenario, it is actually easier to implement, but I could forsee future scenarios where I don't have control over the model and can't get change notification. Thanks for noting this down for a future enhancement. |
|