ODataCollectionView editItem/commitEdit when item not "displayed"

Posted by: develop on 10 January 2018, 2:03 am EST

    • Post Options:
    • Link

    Posted 10 January 2018, 2:03 am EST

    Hi,

    I’ve got a problem when using the editItem/commitEdit method on a ODataCollectionView, which is displayed into a paginated WjFlexGrid.

    Let’s say I’ve two items to update at the same moment :

    • item one is displayed on page 1,
    • item two is displayed on page 2.

      If i use editIem/commitEdit on both items when being on page 1, item 1 will be updated but item 2 won’t - there’s no request emitted.

      Both ODataCollectionView and WjFlexGrid keep on going as if everything was OK.

    Obviously, if I go on page two, it will be the opposite. And if both are on he same page, they will both be updated depending on the page I’m on.

    As I’m used to mistaken between the ODataCollectionView items/sourceCollection properties, I thought it could be related.

    But on my side, I can’t do nothing but to give the item itself…

    At the moment, I found no other solutions but to remove the pagination, which is indeed not a great one.

    If someone could help, it would be amazing :slight_smile:

    Thanks in advance.

  • Posted 10 January 2018, 7:32 pm EST

    Hi,

    If I am correct, you have set pageOnServer to true. That means, you are using server side paging.

    For updating records on different page, you need to set pageOnServer to false. Now, you may change the record on different page using code.

    Please let us know for any further queries.

    ~Manish

  • Posted 11 January 2018, 8:49 pm EST

    Hi,

    Alas no.

    Here’s the configuration :

            const options: any = {
                oDataVersion: 4.0,
                requestHeaders: {
                    Authorization: this.token,
                    "Cache-Control": "no-cache",
                    Pragma: "no-cache"
                },
                pageOnServer: false,
                filterOnServer: false,
                sortOnServer: false,
                keys: this.keys
            }
    

    To illustrate, myCv.items.length gives 30 (items displayed on the current page) but myCv.collectionSource.items.length gives 250.

    I expect the editItem (despite its name) to act on every item from the collectionSource, regardless of the paging.

    Thanks for your help !

  • Posted 14 January 2018, 10:46 pm EST

    Hi,

    Following code should work for you:

     var item= cvData.sourceCollection[0];
                    cvData.editItem(item);
                    item.CustomerID=1;
                    //cvData.commitEdit();
                     var item1= cvData.sourceCollection[10];
                     cvData.editItem(item1);
                     item1.CustomerID=2;
                     cvData.commitEdit();
    

    If this do not work, please share a sample with ODataService.

    ~Manish

  • Posted 17 January 2018, 12:30 am EST

    Hi,

    That’s the piece of code I use.

    • CollectionView side, it works.
    • But it does send a PUT request only if cvData.sourceCollection[x] is on the current page (= accessible in the items property ?).

    Sharing an example with OData is hard, sadly enough. I’m not yet able to do it.

    Thanks for the help :slight_smile:

  • Posted 17 January 2018, 5:01 pm EST

    Hi,

    We are sorry for the inconvenience. This issue requires further investigation. Hence, this issue has been forwarded to the concerned team with internal id 305323. We will let you know as we get any update on this.

    ~Manish

  • Posted 17 January 2018, 11:16 pm EST

    Ok, thank you very much.

  • Posted 30 January 2018, 11:36 pm EST

    Any news about this ?

    I get the same behavior when items are not shown because being filtered (WjFlexGridFilter).

    It’s becoming really problematic…

  • Posted 1 February 2018, 4:36 pm EST

    Hi,

    Thanks foe notifying. We have informed to the concerned team. This issue is with the concerned team.

    ~Manish

  • Posted 2 February 2018, 7:43 pm EST

    Hi,

    We are sorry for the delay.

    Here is the response from the development team:

    We are sorry, currently, This is not supported.

    The CollectionView.editItem method starts by selecting the item. If the item is not in view, it cannot be selected and therefore cannot be edited.

    My suggestion is to simply make the changes using an httpRequest call, then call refresh on the CollectionView to re-load the data.

    ~Manish

  • Posted 12 February 2018, 1:30 am EST

    Sorry, that’s not how it performs. It can’t be an acceptable reply.

    1. I’m using ODataCollectionView, having an HttpRequest has no sense.
    2. The WjFlexGrid and ODataCollectionView are actually updated, only no request is sent so the data is not synchronous.

    I don’t see that editItem also selects the item (it doesn’t seems to, according to point 2), as moveCurrentTo would.

    Is there an Angular2 equivalent for this : http://demos.wijmo.com/5/PureJS/FlexGridPager/FlexGridPager/

    Maybe it could help, right ?

  • Posted 19 February 2018, 12:57 am EST

    Hi,

    There is an Angular2 version of paging at http://demos.wijmo.com/5/angular2/flexgridintro/flexgridintro/. Let me know if this is not what you needed.

    Meanwhile, I am discussing OData issue with the devs.

    ~nilay

  • Posted 27 February 2018, 9:34 pm EST

    Hi,

    It’s not the same paging system. The version I quoted is a grid-level pagination, not a data-level pagination.

    As it mentions :

    [quote]The differences between grid-level pagination and the more traditional data-level pagination provided by the CollectionView class are:

    • The grid-level pagination takes into account the collapsed/expanded state of group rows, so if you collapse or expand a group, the number of rows displayed will correspond to the page size. Data-level pagination does not account for collapsed groups, so if you collapse a group the grid will display fewer rows than the page size.
    • The grid-level pagination keeps all grid rows loaded, and simply hides rows that are not on the current page by setting their height to zero. The data-level pagination loads only the rows that correspond to data items on the current page.


    • [/quote]

    Thanks for your help, but I’m still stuck on this one :frowning:

  • Posted 28 February 2018, 4:37 pm EST

    Hi,

    The ODataCollectionView issue is fixed in an internal build. This would be release in 18v1.

    ~nilay

  • Posted 28 February 2018, 7:59 pm EST

    Hi,

    Please find the attached sample which is Angular2 port of purejs FlexGridPager sample.

    ~nilay

    FlexGridPagerNg2.zip

  • Posted 25 April 2018, 2:03 am EST

    Hi,

    Sorry for the late answer, I was stuck with other projects.

    I made a new pager based on your example. But the same kind of issue appears. As I use an ODataCollectionView, it seems the pager uses only the odatacv.items.length (let’s say 30 items, displayed on the current page) and not the odatacv.collectionSource.items.length (2000), despite the fact they’ve all been loaded because filter/pageOnServer: false.

    So we’re running in the same circle.

    I’ll try to provide a fiddler to illustrate this (and to come back soon :slight_smile: )

    Thanks anyway,

  • Posted 25 April 2018, 3:48 pm EST

    Thanks, we will wait for the fiddle :slight_smile:

Need extra support?

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

Learn More

Forum Channels