Flexgrid Update Row & Hide

Posted by: matth on 14 September 2017, 4:52 am EST

  • Posted 14 September 2017, 4:52 am EST

    I have a read-only flex grid setup that is bound to a view model collection. I am using SignalR hub to update each client. What is the best way, using a client side method, to update a single row of data in the items source?

    Only one of the columns are going to be modified, and if that value is equal to zero the item should be removed from each clients page.

    I know I can repopulate the entire table, but that seems like overkill and could potentially bog down the user experience. It would be much more efficient to only edit the value that is changing and if the value = zero then hide the row.

    Any help would be appreciated.

    Thanks,

    Matt

  • Posted 14 September 2017, 5:05 am EST

    A little more information, when the client method is invoked I will have an IDKey and updated value to pass to the Flex Grid. I need to know how I can update the value by looking up the IDKey and if the value is = 0 to hide the row.

  • Posted 14 September 2017, 8:54 am EST

    Is it possible to use Ajax just to update a single record in collectionView?

  • Posted 14 September 2017, 9:05 am EST

    
    var fg = document.getElementById('flexGrid');
                var wfg = wijmo.Control.getControl(fg).itemsSource.items;
                var item;
                var pos;
                for (var i = 0; i < wfg.length; i++) {
                    if (wfg[i].OrderItemKey === idkey) {
                        item = wfg[i];
                        pos = i;
                        break;
                    }
                }
                wfg[pos].QtyRemaining = wfg[pos].QtyRemaining - qty;
    
    

    I was able to figure out how to get the item and change its value. I just need to make sure to update the UI and if the value is equal or less than zero to hide the row (or delete it). Please help!

  • Posted 15 September 2017, 3:36 am EST

    Someone please help!

  • Posted 19 September 2017, 1:22 am EST

    Thanks for posting this. Sorry for the delay in responding on this.

  • Posted 12 October 2017, 12:53 pm EST

    I figured this out:

    function searchGridandUpdate(idkey, qty) {
                var fg = document.getElementById('flexGrid');
                var wfg = wijmo.Control.getControl(fg).itemsSource.items;
                var item;
                var pos;
                for (var i = 0; i < wfg.length; i++) {
                    if (wfg[i].OrderItemKey === idkey) {
                        item = wfg[i];
                        pos = i;
                        break;
                    }
                }
                wfg[pos].QtyRemaining = wfg[pos].QtyRemaining - qty;
                if (wfg[pos].QtyRemaining <= 0)
                {
                    wijmo.Control.getControl(fg).collectionView.remove(wfg[pos]);
                }
                wijmo.Control.getControl(fg).collectionView.refresh(wfg[pos]);
            };
    
Need extra support?

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

Learn More

Forum Channels