Home Forums WinForms controls Xceed Grid for WinForms Group.TitleFormat

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #14598 |

    Hi all, I have a problem with GROUP title format.
    Let me say that I have a DataTable as DataSource obtained with this SQL statement:

    SELECT T1.ID,
    T1.Data, ‘DateTime Field
    T2,Descr
    FROM T1 INNER JOIN T2 ON T2.IdT1=T1.ID

    In Table T1 I can have record with the same Data
    In Table T2 I can have more than one record related to T1.
    A normal Master/detail scenario

    I need to group By T1.ID, but I’ll like to show in group’s title the value of Data field.
    Is possible to do something like that?

    My question is a simple question, and I’m sure that someone had already faced
    this kind of scenario.
    Thanks in advance, all support will be greatly appreciated.

    Best regards
    SkySurfer72

    Imported from legacy forums. Posted by Gian Luigi (had 2940 views)

    User (Old forums)
    Member
    Post count: 23064

    You need to catch the GroupAdded event on the grid.

    eg.

    this.gcProducts.GroupAdded += new Xceed.Grid.GroupAddedEventHandler(this.gcProducts_GroupAdded);

    private void gcProducts_GroupAdded(object sender, Xceed.Grid.GroupAddedEventArgs e)
    {
    if (e.Group.GroupBy == “ID”)
    {
    e.Group.Title = “Hello World”;
    // e.Group.Key will give you the value of the ID field. You can then do a dbase lookup
    // on the key and set the title of the group to what you want.
    }
    }

    Happy codin.

    Pete.

    Imported from legacy forums. Posted by Peter (had 414 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Pete.
    Thanks for your reply.
    I’ve implemented your solution and this is my result:

    – without specifying any TitleFormat—–> The title group that appear after
    setting e.Group.Title = “Hello World” is “‘Title column’ : Hello World – nr item(s)”

    – Set GroupManagerRow.TitleFormat=””—–> The title group that appear after
    setting e.Group.Title = “Hello World” is blank (empty string)

    And I want also say that as a column of my datatable I have the data that I want to show
    in GroupTitle, so why I have to execute a lot of other query (sometimes more than 1000)
    causing db overload when having a reference to datarow behind group row
    (being able so to retrieve all cell values) should be enough….

    Any further idea?

    Thanks in advance
    Skysurfer72

    Imported from legacy forums. Posted by Gian Luigi (had 366 views)

    User (Old forums)
    Member
    Post count: 23064

    One way you could do it would be to access the DataRow which is passed in with the GroupAddedEventArgs. You could then access either the cell directly, or go through the source object. Upon inspection it seems to pick up the first row from the group, which shouldn’t matter, because if you’re grouping the data you display as the title would be common to all the rows.

    so you could either do.

    e.Group.Title = e.DataRow.Cells[“Data”].Value.ToString();

    or you could access the “Data” field through the SourceObject property of the DataRow. Whichever is easier.

    Let us know how you get on.

    Pete.

    Imported from legacy forums. Posted by Peter (had 4025 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.