Pasted cell is not proper working

Posted by: priya_mehta on 17 July 2018, 3:15 pm EST

    • Post Options:
    • Link

    Posted 17 July 2018, 3:15 pm EST

    As i attached in record, we are using a flexgrid

    in this am trying to copy a value form cell and paste

    but in cell the value is not show directly,if am double click it show

    I have implemented like this for pasted cell, but still its not working

            $scope.initialized = function (s) {            
                s.cellEditEnding.addHandler(function (s, e) {
                    setChanged(e.row, e.col);
                });
    
                s.pastedCell.addHandler(function (s, e) {
                    setChanged(e.row, e.col);
                });
    
                // utility to keep track of changed items
                var changes = [];
                function setChanged(r, c) {
                    if (!getChanged(r, c)) {
                        changes.push({
                            item: s.rows[r].dataItem,
                            prop: s.columns[c].binding,
    
                        });
                    }
                }
    
                function getChanged(r, c) {
                    var cellEdit = false;
                    for (var i = 0; i < changes.length; i++) {
                        var item = s.rows[r].dataItem;
                        var prop = s.columns[c].binding;
                        var ch = changes[i];
                        if (ch.item == item && ch.prop == prop) {
                            cellEdit = true;
                            console.log(changes)
                        }
                    }
    
                    return cellEdit;
                }
    

    PastedCell.zip

  • Posted 17 July 2018, 11:03 pm EST

    Hi,

    Everything in the code-snippet provided looks fine however from the attached video it seems that you are using cell templates. There might be some issue with the templates, can you please share a code snippet of your templates implementation too

    ~Manish

  • Posted 18 July 2018, 6:02 pm EST - Updated 3 October 2022, 11:25 am EST

    ya sure

    here is the template that we use

                <wj-flex-grid-column header="{{'bmad.Assignments.Account' | translate }}"
                                     binding="selectedAccount"
                                     data-type="Object"
                                     width="*">
                    <wj-flex-grid-cell-template cell-type="Cell">
                        <div class="truncate-text-flex" data-qe-id="bmad.account.tooltip - {{$item.sequenceNumber}}">
                            <small ng-style="$item.selectedAccount.accountNumber == null && {'color' : 'rgb(175, 175, 175)'}" data-qe-id="bmad.accountLabel - {{$item.sequenceNumber}}">{{($item.selectedAccount.accountNumber != null)? $item.selectedAccount.accountNumber + ' - ' + $item.selectedAccount.description : 'Start typing or choose from drop down list' }}</small>
                        </div>
                    </wj-flex-grid-cell-template>
                    <wj-flex-grid-cell-template cell-type="CellEdit">
                        <div bento-combobox
                             data-qe-id="bmad.accountinput - {{$item.sequenceNumber}}"
                             columns-width="auto"
                             placeholder="{{'bmad.Assignments.PlaceHolder' | translate}}"
                             get-data="getData()"
                             headers="comboboxData.headers"
                             label-name="label"
                             searchable="true"
                             ng-model="$value"
                             bento-append-to-parent="true"
                             defer-load="true" bento-flex-grid-control>
                        </div>
                    </wj-flex-grid-cell-template>
                </wj-flex-grid-column>
    

    and if it is not clear i also add the snap shot

  • Posted 19 July 2018, 11:05 pm EST

    Hi,

    The problem here is the format of data along with binding specified and cell templates format.

    Allow me to explain:-

    The format of data is somewhat like:-

    {
     
    selectedAccount:{
     
     
    accountNumber:'some value'
     
     
    }
     
    }
    

    The binding specified to column is ‘selectedAccount’ and cell template is {{$item.selectedAccount.accountNumber}}

    Now everything is fine until this point but when we paste something in the column, the pasted value goes on the specified binding. So the dataItem becomes:-

    {
     
    selectedAccount:"pasted value"
     
    }
    

    So now $item.selectedAccount.accountNumber does not exist anymore hence causing cell template to fail.

    To fix this you may use one of the two methods based on your requirement:-

    1). Handle pastingCell event and paste the data into the correct object.

    //Please refer to following code snippet

     
    grid.pastingCell.addHandler((s,e)=>{
          if(e.panel!=s.cells || s.columns[e.col].binding!="selectedAccount"){
            return;
            }
            let pasteData=e.data;
            let dataItem=s.rows[e.row].dataItem;
     
     
    //paste data at right object
     
     
            dataItem.random.key="_"+pasteData;
     
     
    //prevent grid from pasting data
     
     
            e.cancel=true;
          });
    

    2). Change column binding to ‘selectedAccount.accountNumber’, this will instruct the grid to paste data on selectedAccount.accountNumber.

    You may also refer to the following sample:-

    https://jsfiddle.net/pgq1wyz0/2/

    In the sample Templates1 columns implement the first method and Templates2 column implements the other. The second approach is the recommended way.

    ~Manish

  • Posted 31 July 2018, 10:19 pm EST

    Not working for me

    when i copy and paste

    it pasted but value should not directly show

    it show only on double click of cell

  • Posted 1 August 2018, 11:18 pm EST

    Hi,

    We are sorry, we are unable to replicate the issue at our end with the latest build release 5.20182.500 after fixing the above-stated issue.

    Can you please have a look at the following sample and let us know what we are missing to replicate the issue or you may also send a small sample replicating the issue:-

    https://jsfiddle.net/pgq1wyz0/8/

    Also could you please let us know about build version and browser you are using so that we may try once with the same environment?

    ~Manish

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels