I try to use the EditorProviders width the WebDateChooserProvider for date fields this works fine. But when I use the WebDateChooserProvider for a nullable column then I get the error below.
Editor with ID: NullableDateColumn cannot edit column with Key: NullableDateColumn. The editor does not support the column type.
Is it a known issue that WebDateChooserProvider not support nullable datetime fields. Is there a solution to use the EditorProvider for nullable datetime?
Hello,
The problem was not reported to us yet. I have created a bug report for it. Please contact the developer support to be added to the notification list. As soon as the problem is resolved you will be notified. The work item to mention is: 18040.
Thank you.
My dirty solution for so far.
I extend the WebDateChooserProvider class and override the method bool CanEditType(Type t).
This method return now true if it's a datetime field, nullable datetime field or a string. Why the string is necessary? I don't know but it works. When by a string type return false the grid will be display an error if I bind an empty list. I use linq for my database connection and I cast the result recordset to a List<Data model object>.
public class NullableDateTimeEditorProvider : Infragistics.Web.UI.GridControls.WebDateChooserProvider { protected override bool CanEditType(Type t) { if (t.Name.Contains("Nullable")) { return t.FullName.Contains("System.DateTime"); // Nullable datetime support! } else if (t.Name.Contains("String")) { return true; // Strings also true. Why? Read the description } else { return base.CanEditType(t); // Otherwise check the base method } } }
How you you use this NullableDataTimeEditorProvider solution to replace the WebDateChooserProvider? Is there a way to do it in the design mode or must it be done programmatically (add the provider during run time).
ThanksROB
My solution is to implement a class that extends WebDateTimeEditProvider. See my code example earlier in this thread.
In the aspx file you add the NullableDateTimeEditorProvider tag in the EditorProviders tag.
<ext:NullableDateTimeEditorProvider ID="datefield" />
Instead the default WebDateTimeEditProvider .
<ig:WebDateTimeEditProvider id="datefield" />
And you need to register the assembly of the NullableDateTimeEditorProvider in the top of the aspx file.
<%
@ Register Assembly="InfragisticsExtensions" Namespace="InfragisticsExtensions" TagPrefix="ext" %>
I had the exact same problem described above, except with WebNumericEditProvider. First I implemented a custom editor provider as suggested that returned "true" for "System.String" too. But this seemed a like hack to me, so I started to check both the code and the markup and found out the following.
1. You need to specify the DataType attribute on every column you want to make editable.
<ig:BoundDataField DataFieldName="MonthValue1"
Key="MonthValue1" Width="60px" DataFormatString="{0:N2}" DataType="System.Decimal">
</ig:BoundDataField>
2. Wire-up the editor provider with the column in markup
<ig:EditingCore>
<Behaviors>
<ig:CellEditing>
<ColumnSettings>
...
<ig:EditingColumnSetting ColumnKey="MonthValue1" EditorID="wtnpEffortEditorProvider" />
</ColumnSettings>
</ig:CellEditing>
</Behaviors>
</ig:EditingCore>
I'm not sure you _need_ to do it in the markup, I assume the same would work from code-behind, but I had no time to check.
Hope this helps.