jQWidgets Forums

jQuery UI Widgets Forums Grid Having some trouble disabling columnsreorder in jqxGrid

This topic contains 2 replies, has 1 voice, and was last updated by  justin.mann 10 years, 10 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author

  • justin.mann
    Participant

    I am working towards a particularly ugly solution using the grid widget… The ugliness is not associated with your products, they have been a grace just to be clear… I am having one issue I can’t seem to get around at the moment however… I simple want to disable the ability to reorder columns in certain scenarios and re-enable this functionality later. At first glance this seemed nominal, but the functionality listed in the api is simply not working for me (unless I am misunderstanding which is entirely possible).

    I am attempting to initialize the grid with “columnsreorder: true” (which works fine), alter based on some condition I wish to disable this using “$(‘#mySizzleSelectorForYourRockinGrid’).jqxGrid({columnsreorder: true});” and this either fails and I am misunderstanding and it is not a viable option.

    Before I got into coming up with some craziness to achieve functionality I believe you intend to support I figured I’d check with the gurus once again.

    jqWidgets version :
    3.2.2 (currently have the dev [uncompressed] version linked in to my project, but it is unmodified)

    fiddle to demo what I believe to be unintended or failing functionality (no error mind you, just not the outcome I assumed was intended):
    http://jsfiddle.net/justinmann_fiddle/Pr4Js/

    Please do advise,

    With compliments,
    Justin Mann


    justin.mann
    Participant

    In addition, I am using grouping in the grid solution so one work around I thought about and tested is out the window…

    I thought it clever (but perhaps slower) to simply loop thru the current column datafields and pin the columns…
    i.e. –

    var columns = $(“#searchresults”).jqxGrid(‘columns’).records;
    for(i=0;i<columns.length;i++){
    $(‘#searchresults’).jqxGrid(‘pincolumn’,columns[i][‘datafield’]);
    }

    Apparently this is not a viable option due to the solution using grouping… I do find it odd that pinning the columns works fine in my solution, It is the unpinning of the columns that generates errors to the point that pinning of columns is not a viable option when using grouping…
    i.e. –
    var columns = $(“#searchresults”).jqxGrid(‘columns’).records;
    for(i=0;i<columns.length;i++){
    $(‘#searchresults’).jqxGrid(‘unpincolumn’,columns[i][‘datafield’]);
    }

    As stated this is just a work around I thought might get the job done, I’m not intending to confuse the issue.

    Justin


    justin.mann
    Participant

    Problem solved…

    I invoked the render after changing the value of ‘columnsreorder’.

    here is the fiddle illustrating the working behavior…
    http://jsfiddle.net/justinmann_fiddle/Pr4Js/3/

    I believe this was due to the fact that the columnsreorder functionality comes from an extension of the grid… I have no idea really, but I noticed that if I forced my condition where the columns were initialized to be reorderable, then I triggered my condition that should cause them to be UN-orderable (they were still reorderable at this point, which was my original problem), finally I triggered my condition in which they were supposed to be reorderable again (at this point they were UN-orderable). It was as if the grid was one step behind what I wanted it to do so first I tried to simply ‘refresh’ the grid, this did not work so I invoked the ‘render’ method immediately after changing the ‘columnsreorder’ property value and it works like a charm.

    Thanks for any time you spent looking at this, and hopefully this is of use to someone down the line.

    I don’t know if this is intended behavior, but from the documentation the need to invoke the ‘render’ method after changing this particular property was unclear to me. I have other properties I change on the fly conditionally in the same grid framework and they do not require this.

    Not taking anything away from u folks, great product.

    Appreciatively,
    Justin Mann

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

You must be logged in to reply to this topic.