Binding source of FlexGrid to a dynamic class

Posted by: victor.wu on 30 November 2017, 6:05 am EST

    • Post Options:
    • Link

    Posted 30 November 2017, 6:05 am EST

    Hi,

    Is it possible to bind the data source of a FlexGrid to a (dynamic) class which properties are defined during runtime?

    Using the example from the MVCExplorer, I have tried the following but it does not seem to work:

    
    @model IEnumerable<dynamic>
    /* ... */
    @(Html.C1().FlexGrid<dynamic>()
        .Id("ovFlexGrid")
        .AutoGenerateColumns(true)
        .Bind(bl => bl.InitialItemsCount(100).Bind(Model).OnClientQueryData("collectingQueryData"))
        .CssClass("grid")
        .IsReadOnly(true)
        .AutoClipboard(true)
        .SelectionMode(SelectionMode.Row)
        .AllowSorting(true)
        .Filterable(f => f.DefaultFilterType(FilterType.Both).ColumnFilterTypes(filterTypes))
    )
    
    

    This is what I’m passing in through the controller,

    new List<dynamic>(/*Some data*/);
    

    Let me know if you me to attach more code, or elaborate on anything.

    Thanks!

    Victor

  • Posted 4 December 2017, 10:41 pm EST

    Hi,

    We are investigating on this. We will update you soon.

    ~Manish

  • Posted 5 December 2017, 8:04 pm EST

    Hi Victor,

    We are sorry for the late reply.

    This issue requires further investigation. Hence, this issue has been escalated to the concerned team for further investigation.

    ~Manish

  • Posted 11 December 2017, 11:04 pm EST

    Hi Victor,

    We get a sample from Development team for using dynamic class for FlexGrid. Please refer to the attached sample for the same.

    If the issue persists, please let us know how you are filing dynamic list. If possible, please modify the attached sample for the same.

    ~Manish

    C1MVC_InputNumber.zip

  • Posted 18 December 2017, 8:11 am EST

    Hello Manish,

    Thank you for the reply, and providing me the sample - it worked as it is, but when I tried doing a list of ExpandoObjects (apologies; I forgot to mention this in my original post), the table came up empty.

    Based on the sample provided, this is what I tried:

    namespace C1MVC_InputNumber.Controllers
    {
        public class HomeController : Controller
        {
            public ActionResult Index()
            {
                var list = new List<dynamic>();
                dynamic banana = new ExpandoObject();
                dynamic apple = new ExpandoObject();
                banana.Name = "Banana";
                banana.Product = "Fruits";
                apple.Name = "Apple";
                apple.Product = "Fruits";
                list.Add(banana);
                list.Add(apple);
                return View(list);
            }
    }
    

    -Victor

  • Posted 18 December 2017, 7:46 pm EST

    Hi Victor,

    Thanks for your reply. We are able to replicate the issue at our end and it seems a bug. Hence, this issue has been forwarded to the concerned team for further investigation (Id: 301440).

    We will let you know as we get any update on this.

    ~Manish

  • Posted 19 December 2017, 6:26 pm EST

    Hi Victor,

    Currently, C1 MVC serialize the ExpandoObject as a collection. This is logged as bug by development team and will be fixed in next release.

    As a workaround, please find the attached sample to serialzie the ExpandoObject as IDictionary. To make it works, there is a limitation that must set the DisableServerRead = true.

    ~Manish

    C1MVC_FlexGrid_DynamicList.zip

  • Posted 22 December 2017, 3:47 am EST

    Got it. Thank you Manish; I appreciate the help from you and the dev team on this.

    Sincerely,

    Victor

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels