Ticket Q539334
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

How can I use ASPxGridListEditor with XPO classes that have composite keys?

Error to display a detail view with a CompoundKeyStruct and TypeConverter.

created 11 years ago

Hi,
I have implemented a TypeConverter for a CompoundKeyStruct to display the selection column as specified in https://www.devexpress.com/Support/Center/Question/Details/Q368086 and http://msdn.microsoft.com/en-us/library/ayybcxe5.aspx.
But, when I click on a row to display a detail view in view mode, I have this error:

The error occurred:
Type: InvalidOperationException
Message: An error with number 1007 has occurred.
Error message: Unable to execute disabled or inactive action ListViewShowObject. Disable reasons: Requires a single object selected, inactive reasons:
Data: 0 entries
Stack trace:
at DevExpress.ExpressApp.Actions.ActionBase.ExecuteCore(Delegate handler, ActionBaseEventArgs eventArgs)
at DevExpress.ExpressApp.Actions.SimpleAction.DoExecute()
at DevExpress.ExpressApp.Web.Editors.ListEditorContextMenuBase`1.ProcessAction(ActionBase action)
at DevExpress.ExpressApp.Web.Editors.ASPx.ASPxGridViewContextMenu.ProcessCommand(String args)
at DevExpress.ExpressApp.Web.Editors.ASPx.ASPxGridViewContextMenu.ProcessCustomCallback(String parameters)
at DevExpress.ExpressApp.Web.Editors.ASPx.ASPxGridViewContextMenu.DevExpress.ExpressApp.Web.Templates.IXafCallbackHandler.ProcessAction(String parameter)
   at DevExpress.ExpressApp.Web.Templates.XafCallbackManager.ProcessAction(String parameter)
at DevExpress.ExpressApp.Web.Templates.XafCallbackManager.callbackControl_Callback(Object source, CallbackEventArgs e)
at DevExpress.Web.ASPxCallback.ASPxCallback.OnCallback(CallbackEventArgs e)
at DevExpress.Web.ASPxCallback.ASPxCallback.RaiseCallbackEvent(String eventArgument)
at DevExpress.Web.ASPxClasses.ASPxWebControl.System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent(String eventArgument)
     InnerException is null

Why?
I hope you can help me with this issue.

Thanks,
Rossano

Comments (2)
DevExpress Support Team 11 years ago

    Hi Rossano.
    Thank you for contacting us. First, I should mention that support for composite keys in XAF is quite limited. Even the suggestion given in ticket Q368086 is not an ultimate solution. For example, it is impossible to restore a composite key from a string using a type converter if the key structure contain a persistent reference. Would you please provide us with a small sample project demonstrating your scenario? We will research it and do our best to find a solution.

    P P
    Pio Antonio Cartanese 11 years ago

      Hi Michael,
      in attachment an example of a solution that has the problem described above.
      I hope you can help me with this issue.
      Thanks,
      Rossano

      Answers approved by DevExpress Support

      created 11 years ago (modified 7 years ago)

      Hi Rossano.
      17.1.4+
      You can use the StructTypeConverter<T>  for struct key properties to enable some built-in DevExpress.Web.ASPxGridView functions(e.g., inplace editing and the selection column).
      Older versions
      The following type converter seems to solve the issue:

      C#
      public class CKDomainObject1Converter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) return true; if (sourceType == typeof(DevExpress.Xpo.Helpers.IdList)) return true; return base.CanConvertFrom(context, sourceType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { string[] v = ((string)value).Split(new char[] { ',' }); return new DomainObject1.CompoundKey1Struct { Key1 = Convert.ToInt32(v[0]), Key2 = Convert.ToInt32(v[1]), Key3 = Convert.ToInt32(v[2]) }; } if (value is DevExpress.Xpo.Helpers.IdList) { DevExpress.Xpo.Helpers.IdList v = (DevExpress.Xpo.Helpers.IdList)value; return new DomainObject1.CompoundKey1Struct { Key1 = Convert.ToInt32(v[0]), Key2 = Convert.ToInt32(v[1]), Key3 = Convert.ToInt32(v[2]) }; } return base.ConvertFrom(context, culture, value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) return ((DomainObject1.CompoundKey1Struct)value).Key1 + "," + ((DomainObject1.CompoundKey1Struct)value).Key2 + "," + ((DomainObject1.CompoundKey1Struct)value).Key3; return base.ConvertTo(context, culture, value, destinationType); } }
        Show previous comments (4)
        Anatol (DevExpress) 11 years ago

          This is a known issue of version 13.2.9: ASPxGridListEditor - Selection does not work properly for XPO classes with composite keys. It will be fixed with the next update. Please accept our apologies for the inconvenience.

          L L
          Lleonard del Río 11 years ago

            OK, thank you the answer. I have implemented the workaround and works fine.
            Thanks,
            Lleonard.

            Anatol (DevExpress) 11 years ago

              I am happy to hear that. Feel free to contact us if you need further assistance.

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.