jQuery UI Widgets Forums Grid Overactive sort event

This topic contains 12 replies, has 3 voices, and was last updated by  Dimitar 8 years ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
  • Overactive sort event #87941

    TP_DTNA
    Participant

    I’m finding that the sort event is fired not only when a sort occurs, but also if a virtual mode grid is scrolled with a sort applied. Comparatively, the filter event works correctly by only firing when a filter actually occurs and not when the users scrolls the grid.

    It also appears to invoke a redundant call to loadserverdata for whatever it’s doing, but at least I’ve already mitigated the slowness incurred from that function being called more than necessary. See here: http://www.jqwidgets.com/community/topic/virtual-scrolling-increase-recordendindex-and-recordstartindex/#post-87157

    This seems related to a showstopper bug I recently worked around. If a particular div was too short, it would cause an infinite loop only in Internet Explorer with this sort-then-scroll behavior that invokes the overactive sort event. It would oscillate between the rows it should show and the beginning of the set as the cpu could tick. If the loadserverdata call made an ajax call each time, it would just sit and spam the server, but like I said I made an improvement so it just looped itself 100% client-side.

    I tried my best to reproduce it in an isolated demo, but the circumstances are too obscure and I can’t exactly post my real project. This is the closest I could come to reproducing it: http://jsfiddle.net/omjdy9o8/6/

    I’d love to know *why* that happens, but I’m satisfied enough to at least know how to avoid triggering it. If this overactive sort event wasn’t a problem, I doubt that other issue would even exist.

    But that sort event firing upon scroll is a problem for me in that I’m trying to discard selections upon a real sort, not a scroll following a sort. It would also be nice to not waste cpu cycles on a redundant call to loadserverdata.

    Any ideas on how I can detect a sort reliably without using messy hacks?

    Overactive sort event #87978

    TP_DTNA
    Participant

    To give you an idea, this is my hacky workaround. the lsd_lastSd variable is a string assigned in the loadServerData function from the first argument passed to it. The loadServerData() function gets called and sets that value before the source’s sort callback.

    
    var falseSortHack = '';
      var source = {
        datatype:   'json',
        datafields: dataFields,
        id:         dataPriKey,
        url:        url,
        // lose selections upon sort and filter
        filter: function () { clearselection(); $grid.jqxGrid('updatebounddata', 'filter'); },
        sort:   function () {
          // detect bogus sort event
          var falseSort = lsd_lastSd.replace(/startindex=([^&]*)/, '')
                                    .replace(/endindex=([^&]*)/,   '');
          if(falseSort === falseSortHack) {
            console.log('*** FALSE SORT EVENT ***');
            return;
          }
          else {
            console.log('REAL SORT EVENT');
            falseSortHack = falseSort;
            clearselection(); $grid.jqxGrid('updatebounddata', 'sort');
          }
        },
        formatdata:     buildQueryString,
        loadServerData: loadServerData,
      };
    
    Overactive sort event #87998

    AjayTxs
    Participant

    We have been using jqx-grid for binding data in a tab

    actually in an ajax success event we are binding the grid, also we have defined a sort event by which we want to refresh the grid based on sorted column or sorted direction.

    But weirdly the call is leading infinite loop.i.e in the event we have written ajax call from which we aresending sort parameters, the call is hitting the server and this process is going on infinitely.

    we have done this referring to documentation of jqx grid integration with asp.net mvc 4, is their any callback function defined for the sorting in order to refresh grid.

    Overactive sort event #88018

    Dimitar
    Participant

    Hello TP_DTNA,

    Please note that this behaviour does not seem to occur with our own examples, such as the demos Grid Server Sorting, Paging and Filtering and Grid Server Sorting (the source object’s sort callback function is called only when the grid is sorted). Please make sure your client and server sides are correctly set up.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Overactive sort event #88021

    TP_DTNA
    Participant

    Good news everyone! I improved my hack. The earlier one I posted let one false event slip through and this one is better.
    I found out that the sort callback gets two arguments, the field being sorted and a “direction”. On a real sort event, the direction will be one of [true,false,null], which makes a lot of sense and is useful. On subsequent calls that happen upon scrolling (changing the dataview, whatever to call it) that are false sort events, it will send a string like “asc” or “desc”.

    AjayTxs, check this out and see if it doesn’t magically fix your issue:

    var source = {
        datatype: 'json',
        datafields: dataFields,
        id: 'row',
        url: 'asdasd',
        // minimal sort and filter specification
        filter: function() { $grid.jqxGrid('updatebounddata', 'filter'); },
        sort: function(field, dir) {
          // real sort event
          if(dir === true || dir === false || dir === null) {
            $grid.jqxGrid('updatebounddata', 'sort');
          }
          else {
            console.log('*** FALSE SORT EVENT: ABORT SORT CALLBACK ***');
            return;
          }   
        },
        loadServerData: loSeData,
      };
    

    Dimitar – What you’ve noted are unrelated examples that don’t invoke the virtual mode behavior while also ignoring the example I provided that does invoke the behavior. If you care to provide examples that are relevant, I can show you where this happens, but save yourself the time and simply examine the demo I prepared. I updated it to include the improved hack and to only log instances of the loadServerData callback and the false sort events. http://jsfiddle.net/omjdy9o8/8/

    This is a freestanding demo you can run for yourself with your own browser off of jsfiddle. Why are you telling me to check my server and client? Simply run it yourself and see all the false sort events fly down the console. This bug is capable of triggering an infinite loop and was an actual showstopper issue for us until I found a workaround.

    Maybe my solution will help others out there, but more of a problem for me right now is the unresolved selection bug, because selecting grid rows is an important requirement for our needs. I have spent a lot of time discovering bugs in jQWidgets and working around them, and I am *more than happy to help* you or your team resolve them directly. I am offering to work directly with your team all day long if it helps me select more than 20 rows at a time.

    If you’re ready to suggest that I check for problems, the good news is I have! A lot. They are not with my “client and server”, and you now have several neat demos in your hands of where they actually are. Contact me. The more important problems are taking too long to get fixed and I can help you.

    Overactive sort event #88030

    Dimitar
    Participant

    Hello TP_DTNA,

    Thank you for the valuable feedback. We appreciate your effort. I did not ignore your example, but only observed that there is no actual server-side code in it (as well as in your new one) to handle the sorting. Please note that virtual mode works only with server-side sorting (client-side sorting has no effect in this case). Please also note that the example Grid Server Sorting, Paging and Filtering has virtualmode set to true and the code in the sort callback is called only when sorting (this can be checked by placing a breakpoint in it and switching the pages of the grid).

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Overactive sort event #88057

    TP_DTNA
    Participant

    You looked at my example long enough to dismiss it and disregard it in favor or unrelated examples that neither solve my problem (that I’ve already solved with a dumb workaround) nor exhibit the bug I have neatly demonstrated for you. I stand by my use of the word “ignore”.

    Of the three examples you’ve linked, one didn’t even use virtual mode and the other two don’t have much in the way of vertical scrolling. You bring up paging as another way of veering off topic and ignoring the bug I have clearly demonstrated and explained. Providing two of those examples again did not help. If you’re into repetition, try rereading my posts and studying the example I provided.

    And then there’s this: “Please note that virtual mode works only with server-side sorting (client-side sorting has no effect in this case).” If you are not interested in fixing bugs for your paying customers, you can simply be straight and truthful with me about it. If you are hoping I will go away by offering unhelpful examples, please know that this isn’t even the jQWidgets bug that’s holding up my project right now.

    If you are trying to convince me that you don’t understand how your own software works, then this is a good direction to take. How do you think the grids in my example have content? How would the rendergridrows() callback even know what path that data took to arrive at its feet? The fact that I’m randomly generating it client-side for the sake of this example is as irrelevant as everything else you’ve suggested.

    Note this line:
    setTimeout(function() { callback(cb_return); }, 10);

    Just pretend that is an ajax call to a “server” and look for someone else who can explain it to you if you don’t get that.

    The workaround hack I have is good enough for now – I’m okay if you want to leave this issue and put some effort into solving this other one that is holding me up -> http://www.jqwidgets.com/community/topic/multiselect-in-virtualmode/

    Overactive sort event #88061

    Dimitar
    Participant

    Hello TP_DTNA,

    I am sorry my replies were not helpful to you. I assure you no disrespect was meant.

    We will note the issue you specified and our team will look into it in greater detail when possible.

    We would, however, like to ask you to comply to the forum rules when posting, especially these ones:

    – Be respectful and courteous to other users.
    – Communicate with everyone in a professional manner.

    Please also note that this is a community forum and replies can be expected from other users. If you are a licensed customer, please contact our team by email at support@jqwidgets.com.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Overactive sort event #88062

    Dimitar
    Participant

    P.S. We were able to reproduce this behaviour in an example that more closely resembles your scenario: https://www.jseditor.io/?key=virtual-scrolling-sort-callback-1 and have created a work item for it. Again, thank you for your feedback.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Overactive sort event #88078

    TP_DTNA
    Participant

    Thank you for acknowledging the issue.

    My past experience with contacting the support email was not encouraging, so the forums seem like a better place to start looking for a solution. I have spent a lot of time analyzing jQWidgets code to answer some mysteries not covered in the documentation. If you care to offer me any opportunities to help fix the bug I care most about more directly, I’ll be happy to answer the call. Normally with open source projects, I can fix these things myself and submit a pull request for the maintainer to have at their discretion.

    Thank you for the excellent software that we enjoy, use, and rely upon. I look forward to helping ensure quality and shipping a solid product.

    Overactive sort event #88133

    Dimitar
    Participant

    Hello TP_DTNA,

    The following part of the jQWidgets end-user license agreement may answer your question:

    LICENSES INCLUDING SOURCE CODE

    In some cases you may purchase licenses which include the source code of the Software. The source code contains the non-minified original JavaScript, HTML & CSS files of the Software. The source code of the Software is an important intellectual property of the Author. Purchasing a license with source code does not constitute transfer of any IP rights or legal ownership to the Software or its source code. You may use the source code of the Software according to the following conditions:
    – You may examine, debug and introduce modifications to the Software and its source code in order to provide better integration with your web sites, applications or other products. You may incorporate the original or modified version of the Software within your products but only in minified (obfuscated) format.
    – You are not allowed to distribute, share, disclose or otherwise make available any portion of the original or modified and non-minified Software source code to end users or other third parties.
    – You agree not to use the Software and/or its source code to plan, design or develop products, libraries or other derivative products that resemble or compete with the Software.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Overactive sort event #88168

    TP_DTNA
    Participant

    Thanks, but I’m not sure if we have that and I didn’t find any information on the site about how to get it. We can probably make it happen if it’s an option, and I’ll check into that. Thanks! What I’m ultimately after is this:
    “multiplerowsextended” – users can select multiple rows with drag and drop or
    by clicking on rows while holding Ctrl or Shift.

    I need for that feature to work, and I’m not sure how best to get things fixed other than to tinker with them enough to craft a workaround. Most of the answers I get tend to suggest alternatives that amount to not using the feature I’m trying to resolve in the first place. I do a lot of work with an un-minified version of jqwidgets full of logging code so that I can see what’s happening and what happens internally. It helps me notice certain behavior that is 100% reproducible, and I hope to cultivate some constructive dialogue about undesired behavior (or if it’s not a bug, but a feature!) and how to handle it better.

    It appears that the virtual mode feature has a couple rough edges, but otherwise it’s working great for our purposes. Showing data in this way is a really great use of the jqXgrid that I think would delight people who want > 40k rows. I will shed a little tear of joy when the time comes that I see it working 100% as I hope it can, because I know it is possible. Thank you very much for you help and apologies for my rudeness in pursuit of great software.

    Overactive sort event #88185

    Dimitar
    Participant

    Hello TP_DTNA,

    If you have a Developer or Enterprise license, you have access to the jQWidgets source code via the jQWidgets Client Portal. If not, please contact our Sales department at sales@jqwidgets.com for available options on the matter and more information if necessary.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.