Author Topic: MargeCells is unjust.  (Read 3629 times)

eloan

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 25
    • View Profile
MargeCells is unjust.
« on: October 24, 2016, 01:15:34 pm »
Hi.

I used function to mergeCells and freezeCols.
If the certain column was made hidden, the reach of merging became unjust.

please, help me.
=== step ===
1. test source is used for under.
2. access by web browser. click button on "Test1 Hidden" and "Test2 Hidden".
3. Test3 column Merge is 1 colspan. but it increases in colspan 2. And right data slips.

=== test source ===
<script>
$(function () {
    var obj = { width: 400, height: 200 };
    obj.colModel = [ { title:"Test" , dataIndx:"a" }
                ,{ title:"Test2", dataIndx:"b" }
                ,{ title:"Test3", dataIndx:"c" }
                ,{ title:"Sum", dataIndx:"sum" }
                ,{ title:"data1", dataIndx:"data1" }
                ,{ title:"data2", dataIndx:"data2" }];
    obj.freezeCols = 4;
    obj.dataModel = { data: [{ "a":"test1", "b":"2", "c":"3", "sum":"6", "data1":"1", "data2":"5" }
                   ,   { "a":"test1", "b":"2", "c":"3", "sum":"6", "data1":"2", "data2":"4" }]};
    var $grid = $("#grid").pqGrid(obj);
   var mergeAry = [];
   mergeAry.push({r1: 0, c1: 0, rc:2, cc:1});
   mergeAry.push({r1: 0, c1: 1, rc:2, cc:1});
   mergeAry.push({r1: 0, c1: 2, rc:2, cc:1});
   mergeAry.push({r1: 0, c1: 3, rc:2, cc:1});
   $grid.pqGrid({mergeCells: mergeAry});
   $grid.pqGrid("refreshView");

});

function chgColumn() {
   var colModel = $("#grid").pqGrid("getColModel");
   var mergeAry = [];
   mergeAry.push({r1: 0, c1: 0, rc:2, cc:1});
   mergeAry.push({r1: 0, c1: 1, rc:2, cc:1});
   mergeAry.push({r1: 0, c1: 2, rc:2, cc:1});
   $("#grid").pqGrid({mergeCells: mergeAry});
   $("#grid").pqGrid("refreshView");
}
function chgHidden(i) {
   var colModel = $("#grid").pqGrid("getColModel");
   colModel.hidden = !colModel.hidden;
   $("#grid").pqGrid("option", "colModel", colModel);
   $("#grid").pqGrid("refreshView");
}

</script>
<body>
<input type="button" onclick="chgHidden(0);" value="Test1 Hidden">
<input type="button" onclick="chgHidden(1);" value="Test2 Hidden">
<input type="button" onclick="chgHidden(2);" value="Test3 Hidden">

<div id="grid" style="margin:auto;"></div>

</body>


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: MargeCells is unjust.
« Reply #1 on: October 24, 2016, 01:38:23 pm »
Thanks for reporting the issue. I'm looking into it.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: MargeCells is unjust.
« Reply #2 on: October 24, 2016, 09:03:22 pm »
Please use the attached patch for this issue.

The patch file can be included after pqgrid.min.js file.

eloan

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: MargeCells is unjust.
« Reply #3 on: October 25, 2016, 06:14:19 am »
I'll be thankful for quick correspondence.

It was checked.
But it was insufficient.

The one indicated first is a simple source, and actual condition uses by 6 columns in front of sum.
A problem wasn't settled in this case.
When "Test1"~"Test3" is changed to hidden, it occurs.

Please look it.

=== Source near practical use ===
<script>
$(function () {
    var obj = { width: 400, height: 300 };
    obj.colModel = [ { title:"id",    dataIndx:"id", hidden: true }
                ,{ title:"Test" , dataIndx:"a" }
                ,{ title:"Test2", dataIndx:"b" }
                ,{ title:"Test3", dataIndx:"c" }
                ,{ title:"Test4", dataIndx:"d" }
                ,{ title:"type", dataIndx:"type" }
                ,{ title:"Sum", dataIndx:"sum" }
                ,{ title:"data1", dataIndx:"data1" }
                ,{ title:"data2", dataIndx:"data2" }];
    obj.freezeCols = 7;
    obj.dataModel = { data: [{ "id":"1", "a":"test1", "b":"2", "c":"3", "d":"4", "type":"A", "sum":"6", "data1":"1", "data2":"5" }
                   ,    { "id":"2", "a":"test1", "b":"2", "c":"3", "d":"4", "type":"B", "sum":"6", "data1":"2", "data2":"4" }]};
    var $grid = $("#grid").pqGrid(obj);
   var mergeAry = [];
   mergeAry.push({r1: 0, c1: 1, rc:2, cc:1});
   mergeAry.push({r1: 0, c1: 2, rc:2, cc:1});
   mergeAry.push({r1: 0, c1: 3, rc:2, cc:1});
   mergeAry.push({r1: 0, c1: 4, rc:2, cc:1});
   $grid.pqGrid({mergeCells: mergeAry});
   $grid.pqGrid("refreshView");

});

function chgHidden(i) {
   var colModel = $("#grid").pqGrid("getColModel");
   colModel.hidden = !colModel.hidden;
   $("#grid").pqGrid("option", "colModel", colModel);
   $("#grid").pqGrid("refreshView");
}

</script>
<body>
<input type="button" onclick="chgHidden(1);" value="Test1 Hidden">
<input type="button" onclick="chgHidden(2);" value="Test2 Hidden">
<input type="button" onclick="chgHidden(3);" value="Test3 Hidden">
<input type="button" onclick="chgHidden(4);" value="Test4 Hidden">

<div id="grid" style="margin:auto;"></div>

</body>

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: MargeCells is unjust.
« Reply #4 on: October 25, 2016, 03:31:41 pm »
Please find attached updated patch for this issue and let me know if you face any other issue.

eloan

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: MargeCells is unjust.
« Reply #5 on: October 26, 2016, 05:30:30 am »
Thank you very much.
A problem was settled.

I have one question.
Is this patch included by the next version?
« Last Edit: October 26, 2016, 05:41:18 am by eloan »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: MargeCells is unjust.
« Reply #6 on: October 26, 2016, 08:56:34 am »
You are welcome!

Yes this patch would be applied to the next version.

eloan

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: MargeCells is unjust.
« Reply #7 on: October 26, 2016, 10:57:40 am »
OK!
very thanks!!

Best Regards.