Add , remove rows and collect in (WIJMO Flex Grid ([b]Pure Js[/b] Mode))

Posted by: m.omar on 12 May 2018, 6:08 pm EST

    • Post Options:
    • Link

    Posted 12 May 2018, 6:08 pm EST

    Salam Alykom,

    Could you please provide me with in (WIJMO Flex Grid (Pure Js Mode)):

    1- A simple and clean way to add and remove rows from from external button.

    2- A simple and clean way to collect and tracking the data changes from the grid in propose to save it into DB, (added,updated, delete) rows and cells.

    Thanks.

  • Posted 14 May 2018, 2:10 pm EST

    Hi,

    You can add Number of Rows at the top using insert method of RowCollection class. Please refer to following code snippet for adding the new Rows at the top:

    var row= new wijmo.grid.Row();
    grid.rows.insert(index,row);
    

    For deleting rows please use this code.

    deleteRow() {
            let order = 5,
                c = {};    ;
            for (var j = 0; j< this.flex.rows.length - 1; j++) {
                if (this.flex.rows[j].dataItem.id == order) {
                     c = this.flex.rows[j];
                    break;
                }
            }
            this.flex.rows.remove(c);
        }
    

    Please refer to the Change Tracking Sample Section of the Collection View Sample to know about howto detect changes

    http://demos.wijmo.com/5/purejs/collectionviewintro/collectionviewintro/

  • Posted 14 May 2018, 6:05 pm EST

    Hi Omar,

    In above code snippet, the code error is in for loop condition and item passed to delete, it should be like as follows:

    function removeAllRows(id){
    	var grid= wijmo.grid.FlexGrid.getControl("#"+id);
      if(!grid){
      	return;
      }
     [b] var rowCount=grid.rows.length;[/b]
      for(var i=0;i<[b]rowCount[/b];i++){     
        grid.rows.remove(grid.rows[[b]0[/b]]);    
      }
      
    }
    

    Here is why, this should be like above:

    wijmoGridObject.rows.length gets reduce by one on removing item from array.

    wijmoGridObject.rows[j] The index gets changed once the item is removed from the array.

    Hope it clears!

    ~Manish

  • Posted 14 May 2018, 6:07 pm EST

    What is the wrong in the following codes:

     function deleteAllRows(wijmoGridObject)
        {
            if (wijmoGridObject == null)
                return;
    
          
            for (var i = 0; i< wijmoGridObject.rows.length - 1; i++) {
                wijmoGridObject.rows.remove(wijmoGridObject.rows[i]);
            }
        }
    

    Or

    
    function deleteAllRows(wijmoGridObject)
       {
           if (wijmoGridObject == null)
               return;
    
            wijmoGridview = wijmoGridObject.collectionView;
           for (var i = 0; i< wijmoGridview.items.length - 1; i++){
               wijmoGridview.remove(wijmoGridview.items[i]);
           }
       }
    

    My target is to impalement a function to delete all rows, but when i used any of these 2 functions , the result is delete some of rows not all rows >>for example if i have grid with 5 rows and call any of these 2 functions it delete only 2 or 3 rows only !!

  • Posted 14 May 2018, 6:10 pm EST

    Thanks alot.

Need extra support?

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

Learn More

Forum Channels