Author Topic: Row grouping by few fields  (Read 3212 times)

youngvan

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 42
    • View Profile
Row grouping by few fields
« on: June 17, 2014, 06:48:23 pm »
Hey,

Is it possible to make a group by few fields simultaneously?
For example I wanna make group by Country and City.
CountryCityDistrict
EnglandLondonGreenwich
EnglandLondonCroydon
EnglandLondonBromley

I've tried to add group index:
Code: [Select]
groupModel : ['2fieldGroup'] and add
Code: [Select]
dataIndx : "2fieldGroup" at first column of header.
After this for each row with data I add
Code: [Select]
$row['2fieldGroup'] = "England_London";It works but in this case Country column shows "England_London" instead of just "England"
Any suggestions?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: Row grouping by few fields
« Reply #1 on: June 17, 2014, 07:24:53 pm »
I'm not sure whether I got your question completely but grouping by multiple fields is simple.

Code: [Select]
groupModel:{
            dataIndx: ["Country","City"]
        },           

Example:
http://paramquery.com/pro/demos/group_rows

youngvan

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: Row grouping by few fields
« Reply #2 on: June 17, 2014, 08:49:41 pm »
I saw this option, it's not what I really need.
I'd like to have a possibility to group by just one field but value of this field should consist of two other (Country + City)
Maybe it's possible to set two different values for cell: one for grouping("England_London") and second parameter which should be displayed in table("England"), so "group by" value of cell will be different from "displayed" value in table.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: Row grouping by few fields
« Reply #3 on: June 17, 2014, 09:42:27 pm »
view can be different from the data in a cell

use column.render callback

render: function(ui){
  return ui.rowData["Country"]+"-"+ui.rowData["City"];
}

API ref:
http://paramquery.com/pro/api#option-column-render