Author Topic: AutoSum function, sum and max text change,Is it possible?  (Read 145 times)

necatiozbek

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 19
    • View Profile
AutoSum function, sum and max text change,Is it possible?
« on: July 18, 2024, 06:50:32 pm »
I am using the AutoSum function. but at the bottom there is the word "sum" in the grandSummary field. Can we change this "Toplamlar" expression?

There is also a checkbox in the grandsummary field that shouldn't be there.

Please review the attached image.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6296
    • View Profile
Re: AutoSum function, sum and max text change,Is it possible?
« Reply #1 on: July 19, 2024, 05:52:17 pm »
If you want to configure sum text in summary row for all columns, then use summaryTitle option

https://paramquery.com/pro/api#option-summaryTitle

If you want to do it for only one / few columns but not all, then use column.render for that column.

Code: [Select]
column.render = function(ui){
  return ui.formatVal;
}

checkbox is not added in the summary row by default, please share your definition of checkbox column and summary rows.

necatiozbek

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: AutoSum function, sum and max text change,Is it possible?
« Reply #2 on: July 19, 2024, 10:46:13 pm »
My object does not have a setting for the selection box to appear in the summary area

Also I don't know how to use SummaryTitle. I couldn't do it.

I'm trying other options for aggregation (Custom summary), but the summary field gets corrupted when I group the columns.

MycolModel: [

{
           // This field is actually an integer field, consisting of 1 and 0. I turned the integer field into a selection box.

            title: "İstisnalı",
            dataIndx: "ISTISNA_FATURA", dataType: "integer", align: "center",
            width: 70,
             editor: false,
             editable: false,
                     type: 'checkbox',
                       cb: {
                                        all: false,
                                        header: true,
                                        check: 1,
                                        uncheck: 0
                              },
                             render: function (ui) {
                                 var cb = ui.column.cb,
                                       cellData = ui.cellData,
                                       checked = cb.check === cellData ? 'checked' : '',
                                       disabled = this.isEditableCell(ui) ? "" : "disabled",
                                       text = cb.check === cellData ? '1' : (cb.uncheck === cellData ? '0' : '<i>bilinmez</i>');
                                       
                                    return {
                                                text: "<label><input type='checkbox' " + checked + " /></label>",
                                             };
       },
                      These are the columns I calculated total
       {
                                    title: "Ft Genel Toplam", dataIndx: "FT_GENEL_TOPLAM", dataType: "float", format: '##,###.00',
                                    summary: {
                                        type: "sum"
                                    },
                                   
        },
        {
                                    title: "Tevkifatlı KDV Toplam", dataIndx: "TEVKIFATLI_KDV_TOPLAMI", dataType: "float", format: '##,###.00',
                                    summary: { type: "sum" },
        }
]

var obj_my_grid = {
showTitle: false,
editable: false,
resizable: true,
.,
.,
.,
//This is the only place in the object related to the total
groupModel:  {
                            on: true,
                            dataIndx: [],
                            collapsed: [true, true],
                            merge: false, 
                            showSummary: [true, false],
                            grandSummary: true, 
                        },
}
var grid_invoice_List=  pq.grid("#grid_filter", obj_my_grid);



paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6296
    • View Profile
Re: AutoSum function, sum and max text change,Is it possible?
« Reply #3 on: July 22, 2024, 02:38:35 pm »
1)
column.render callback is called for cells in grid as well as summary rows.

Either you can use the grid API to render checkbox columns by adding type: 'checkbox' to the columns and map 1 to check and 0 to uncheck similar to this example:

https://paramquery.com/pro/demos/checkbox

Code: [Select]
type: 'checkbox', //required property.
cb: {
    header: true, //for header checkbox.
    check: 1, //check the checkbox when cell value is 1
    uncheck: 0 //uncheck when 0
},

or if you want to use custom render function to display checkboxes, then you can exclude the summary row by adding a check for summary row meta data.

Code: [Select]
if( ui.rowData.pq_grandsummary ){ //grand summary row.
   return ""; //no checbox
}


2)

add this in the grid initialization options:

summaryTitle:{ sum:"{0}"},
« Last Edit: July 22, 2024, 02:44:05 pm by paramvir »