使成组的行在angular-slickgrid中可编辑

时间:2019-05-07 14:42:18

标签: angular slickgrid

在实现angular-slickgrid时,我需要使分组行(格式化程序:一组子行的总和)可编辑,然后将值传递给该组的子行。 在保持引用相同的情况下如何实现?

1 个答案:

答案 0 :(得分:0)

groupByDurationEffortDrivenPercent() {
    // ${GroupTotalFormatters.sumTotals(g.totals,columns[6])}
    var columns=this.columnDefinitions
    this.dataviewObj.setGrouping([
      {
        getter: 'duration',
        formatter: function(g){

          let ff= JSON.stringify(g.rows)
          let tester=89

          return `Duration:  ${g.value}  <span style="color:green">(${g.count} items)</span><div onclick='x=dissagregate(${ff},this);console.log(x)' class="slick-cell l7 r7">${GroupTotalFormatters.sumTotals(g.totals,columns[6])}</div> 
          <script>
              function dissagregate(x,z,y){
                child=x[0]
                child['cost']=200

                old_value=  parseFloat(y.innerText)

                if(isNaN(old_value)){

                }
                else{

                  var html="<input type='text' value='" + old_value + "' onblur='changeinput(this)'  >"
                  y.removeChild(y.firstChild)
                  y.innerHTML=html


                }
                return x;
               }

              function changeinput(ele){
                var parent= ele.parentNode
                var val = ele.value;
                parent.innerText=val
              }


          </script>

          `;
        },
        aggregators: [
          new Aggregators.Sum('duration'),
          new Aggregators.Sum('cost')
        ],
        aggregateCollapsed: true,
        lazyTotalsCalculation: false,
        displayTotalsRow:false

      },