Author Topic: Can I add a sub-total for each group change in groupModel  (Read 9432 times)

lsl

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Can I add a sub-total for each group change in groupModel
« on: January 02, 2015, 02:43:38 pm »
I want to have a grid with single group field but

1) Display multiple fields.
    I want a grid with an invoice list sorted by customer code. But it was broken by customer code and showed customer code, customer name, telephone and fax in the header line (Just one single line)
2) Showing the sub-total for each break

Code,Name,Telephone,Fax
Invoice 1, Date1, Cur1 , Amount1,ExRate1, Balance1
Invoice 2, Date2, Cur2 , Amount2,ExRate2, Balance2
                                                                      Sub-total
Code2,Name2,Telephone2,Fax2
Invoice 3, Date3, Cur3 , Amount3,ExRate3, Balance3
Invoice 4, Date4, Cur4 , Amount4,ExRate4, Balance4
                                                                      Sub-total
                                                                      Total

Thanks




paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: Can I add a sub-total for each group change in groupModel
« Reply #1 on: January 05, 2015, 10:47:05 am »
Subtotal can be displayed for every change in group field with help of column.summary option.

http://paramquery.com/pro/api#option-column-summary

Example: There is sub total and total displayed for freight field in this demo:
http://paramquery.com/pro/demos/group_rows


Title of the group can display only the field value which caused the grouping and number of items/sub-items.

lsl

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Re: Can I add a sub-total for each group change in groupModel
« Reply #2 on: January 05, 2015, 10:00:33 pm »
Thanks.

I want to change the color of the sub-total row.
Can I change the class of sub-total row ? or able to define pq_rowcls on the sub-total row.


lsl

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Re: Can I add a sub-total for each group change in groupModel
« Reply #3 on: January 06, 2015, 02:50:49 pm »
In the example, there are two levels of sub-total. It is better to show the group caption beside the sub-total. For example, showing "Yvonne Moncada" in the "Order Date" column at the "sub Total:306.64" row and showing "Argentina" in the "Order Date" column at the Total:598.58" row.

Can I do that?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: Can I add a sub-total for each group change in groupModel
« Reply #4 on: January 06, 2015, 05:21:14 pm »
It's not supported currently. We would check its viability for the next version thanks for your feedback.

lsl

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Re: Can I add a sub-total for each group change in groupModel
« Reply #5 on: January 14, 2015, 01:52:17 pm »
It works fine for showing grouping head and sub-total.

However , I want to do further enhancement so that the grid able to add and edit the records.
It will be error when I want to add the records. it shows "Uncaught TypeError: Cannot read property 'push' of undefined"
in field pqgrid.dev.js in line 9595

cols[dataIndx].push(rowData[dataIndx]).

But there is no error for editing the grid.





paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: Can I add a sub-total for each group change in groupModel
« Reply #6 on: January 15, 2015, 11:30:40 am »
Please check and assign dataIndx correctly.
« Last Edit: January 15, 2015, 11:32:11 am by paramquery »

lsl

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Re: Can I add a sub-total for each group change in groupModel
« Reply #7 on: January 18, 2015, 12:39:29 pm »
The error occurred when it was set as

       var rowIndx =  $grid.pqGrid( "addRow", { rowData: obj, rowIndx:0 }) ;

That is, it will be at the first line to input the record when it has the grouping after I pressed the add record button.
When there has data in the grid, the first line supposed to be the grouping and pqgrid will try to use such structure to build up the first line, I think.
 
If I change the coding as follows,
     var rowIndx =  $grid.pqGrid( "addRow", { rowData: obj}) ;

That is,it will be at the last line to input the record. If there has data in the grid, it works fine.
But, if there is no data in the grid, the error still occurs.

Can it be solved if I want to use the first line to edit the adding record and the case of no data?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: Can I add a sub-total for each group change in groupModel
« Reply #8 on: January 19, 2015, 12:00:17 pm »
I couldn't find any issue. Please see this example when there is no data in the grid.

http://jsfiddle.net/uatce4at/

lsl

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Re: Can I add a sub-total for each group change in groupModel
« Reply #9 on: January 19, 2015, 12:31:38 pm »
I made a modification to your jsfiddle, actually we are adding a new row with no initial data inside. (screen attached)
and when i push the "+" button, the error pops up.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: Can I add a sub-total for each group change in groupModel
« Reply #10 on: January 20, 2015, 12:56:41 pm »
Grouping can't take place when group by fields are missing and hence the error.

You could toggle the grouping for the grid. When user adds a new row with missing group by fields missing, remove the grouping and when the user is done entering the data for that row, re-enable the grouping.

lsl

  • Pro Deluxe
  • Jr. Member
  • *
  • Posts: 67
    • View Profile
Re: Can I add a sub-total for each group change in groupModel
« Reply #11 on: January 20, 2015, 02:21:57 pm »
I have solved the problem by putting a '*' in the grouping field

Thanks

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: Can I add a sub-total for each group change in groupModel
« Reply #12 on: February 17, 2015, 11:10:57 pm »
Quote
Thanks.

I want to change the color of the sub-total row.
Can I change the class of sub-total row ? or able to define pq_rowcls on the sub-total row.

You can add classes to the grouping title and summary rows in v2.4.0
http://paramquery.com/pro/demos/group_rows

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: Can I add a sub-total for each group change in groupModel
« Reply #13 on: February 17, 2015, 11:12:07 pm »
Quote
In the example, there are two levels of sub-total. It is better to show the group caption beside the sub-total. For example, showing "Yvonne Moncada" in the "Order Date" column at the "sub Total:306.64" row and showing "Argentina" in the "Order Date" column at the Total:598.58" row.

Can I do that?

You can do it in v2.4.0
http://paramquery.com/pro/demos/group_rows