0

consider the code :

localStorage.setItem(gridNameForUDF + ' - frozen columns', '2');
jq(document).ready(function() {

    var VFPAGE = '  TestPage';
    var currentLocation = window.location.href;
    var newLocation = currentLocation.replace('gblite.','c.');
    newLocation = newLocation.substring(0, newLocation.indexOf('Grid?')) + VFPAGE;
    var gridInfo = getGridInfoByName('p');  
    var priceBookEntryIdMetaCol;
    //console.log('VFPAGE '+VFPAGE);
    for (var i=0; i<gridInfo.metaColumns.length; i++) {
        var thisCol = gridInfo.metaColumns[i];

        if (thisCol.fieldName == '****') {
            **** = thisCol;

            break;
        }
    }
    var dataRows = jq('table#gbMainTable > tbody > tr.dr');
    dataRows.find('td[name="' + ****.fieldId + '"]').each(function() {

        var cell = jq(this);
        var recordId = cell.closest('tr').attr('id');

        console.log('====cell====',cell.find('td').find('span'));
        cell.on('click', function(e) { 
            console.log('=======cell=====');
            e.stopPropagation(); 

            window.open(newLocation + '?oliId=' + recordId, '_blank');
        });
    });
});

At top I am setting some values in localstorage to set the first two columns of my grid freeze. And then registering an onclick event on a cell. Now what happens is , the onlclick gets registered well, but after the js loads fully the class name if the cell gets changed to 'ui-selectee none' where as if I remove the frozen column code localStorage.setItem(gridNameForUDF + ' - frozen columns', '2'); then the class name is 'ui-selectee'. Hence the cell on click does not work. Including frozen column creates a another div component.

Is there a solution for this? I cannot use getElementById, I cannot remove the frozen column code too.

  • 1
    if you add the onclick on the cell it would be there, I am guessing the table is redrawn and you lose your event handlers. – epascarello Aug 31 '17 at 04:10
  • Yes, I see after a few seconds the table is redrawn and the frozen column appears. Is there a way to register the onclick handler even after the table is redrawn. – RahulSingh123321 Aug 31 '17 at 04:12
  • Figured it out, when the frozen column is introduced. There are two tables created, one the mainTable and the new one which is named as mainTableCloned. Hence the event on the mainTable is not able to recognize the cells from mainTableCloned. I am now registering the events on both the table after few seconds with setTimeOut. And now it works fine. – RahulSingh123321 Aug 31 '17 at 08:10

0 Answers0