Using MultiRow with Entity Framework

Posted by: domsinclair on 3 August 2017, 2:34 pm EST

  • Posted 3 August 2017, 2:34 pm EST

    Hi

    I'm currently evaluating spread nd have been looking at the multirow control. As I'm already a C1 user I am interested in seeing if this will work with other c1 controls , in this specific instance the c1 datasource .

    I have created a new project in vs 2012 (using VB as opposed to C#) and created a new entity data model in it based on our old friend Northwind. On a new form I have added a c1 datasource and set it's viewsource to be 'Orders'.

    Having set up the datasource I then dragged a multirow control onto the form, setting it's template property to default and it's datasource property to the c1 datasource. I then set the datmember property of the multirow to be 'Orders'.

    With this all done I had expected to be avble to work the the multirow and edit the template but it would seem that I can't. So two questions.

    1) Can the Multirow work with the entity framework and in particular with the c1 datsource form the studio for entity framework. If it can, can you provide a small sample demonstrating it.

    2) There appears to be no option to add a multirow template in the add items list in visual studio 2012 or indeed visual studio 2013. Is multirow compatible with these newer visual studio environments?

    Thanks

    Dom
  • Replied 3 August 2017, 2:34 pm EST

    Hi Folks

    Any thoughts on this?

    Dom
  • Replied 3 August 2017, 2:34 pm EST

    Hello Dom,

    Sorry for the delay on this thread.
    I was able to replicate the issue and have escalated it to the concerned team for review. I would get back to you as soon as I receive any update from them.

    Regards
  • Replied 3 August 2017, 2:34 pm EST

    Hello Dom,

    As per the development team, you need to set DataColumn.Name string to MultiRow Cell.DataField property to tell MultiRow which cell will display which column data from DataSource. So, the entire steps should be following:

    1. Create a WinForm application
    2. Click on Project option and add ADO.Net Entity model
    3. Create a new entity data model say using Northwind database
    4. On a the form, add C1Datasource control of Studio for Winforms and set it’s viewsource to 'Orders’.
    5. Now, drag a GcMultiRow control onto the form, set it’s template property to default and it’s datasource property to the C1Datasource. Also, set the Datmember property of the GcMultiRow to 'Orders’.
    5.1: Set Cell.DataField to DataColumn.Name.
    private void Form1_Load(object sender, EventArgs e)
    {
    Template template = this.gcMultiRow1.Template;

    template.Row.Cells[0].DataField = "Customer";
    template.Row.Cells[1].DataField = "Employee";
    template.Row.Cells[2].DataField = "Order Date";
    template.Row.Cells[3].DataField = "Ship Via";

    this.gcMultiRow1.Template = template;
    }

    Let me know if this does not works for you.

    Regards
  • Replied 3 August 2017, 2:34 pm EST

    Hi Ashish

    Many thanks for getting back to me. I have done as you suggested (adding the following code to my form);

    Imports GrapeCity.Win.MultiRow

    Public Class Form1

    Private Sub Form1_Load( sender As Object, e As EventArgs) Handles MyBase.Load
    Dim template As Template = Me.gcMultiRow1.Template

    template.Row.Cells(0).DataField = "Customer"
    template.Row.Cells(1).DataField = "Employee"
    template.Row.Cells(2).DataField = "Order Date"
    template.Row.Cells(3).DataField = "Ship Via"

    Me.gcMultiRow1.Template = template

    End Sub
    End Class


    However as you will see from the attached image results were not entirely as expected. Obviously it is picking up something but as you will see from the MultiRow image attached not quite what was expected.

    I then went on to change the code slightly as follows:

    Private Sub Form1_Load( sender As Object,  e As EventArgs) Handles MyBase.Load
    Dim template As Template = Me.gcMultiRow1.Template

    template.Row.Cells(0).DataField = "Customer"
    template.Row.Cells(1).DataField = "Employee"
    template.Row.Cells(2).DataField = "OrderDate"
    template.Row.Cells(3).DataField = "ShipVia"

    Me.gcMultiRow1.Template = template

    End Sub


    Removing the spaces in 'Order Date' and 'Ship Via' had some effect as you can see from image MultiRow1, but still not quite was one might have expected.

    MultiRow is still very new to me (as indeed is spread) so I may well be missing some obvious other properties that I ought to be setting. I'd welcome your comments.

    Regards

    Dom



  • Replied 3 August 2017, 2:34 pm EST

    Hello Dom,

    I tried replicating the issue by setting the column names of Category table to the DataField property but it worked properly at my end. Here is the code I used after binding GcMultiRow with the Categories table:

       Dim templte As Template = GcMultiRow1.Template
    templte.Row.Cells(0).DataField = "CategoryID"
    templte.Row.Cells(1).DataField = "CategoryName"

    GcMultiRow1.Template = templte


    Kindly make sure that you have set correct name to the DataField property same it is there in the database.

    Regards
Need extra support?

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

Learn More

Forum Channels