jQWidgets Forums

jQuery UI Widgets Forums Grid Setting hidecolumn property

This topic contains 2 replies, has 2 voices, and was last updated by  admin 2 years, 9 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Setting hidecolumn property #122342

    millhorn
    Participant

    Hello,

    I’m trying to work with the hidecolumn property. In this demo, I have it set up properly and the named column (legalName) is properly hidden. However, in my localhost, I’m unable to get this to work properly. The demo is set up the same way as it is in my localhost development.

    My question is: Is there a dependency I might be missing locally that is causing hidecolumn to not work properly? The Codepen demo is pulling everything in from the CDN (https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/14.0.0/jqwidgets/jqx-all.js), but I have a licensed edition and I’m using the various individual script references (seen below).

    image of jqwidgets script references

    What am I missing?

    Setting hidecolumn property #122343

    millhorn
    Participant

    It turns out I wasn’t able to hide the column with the single line, but if I embed the property in an if/else, inside a function… then it works fine. Seems counter-intuitive as I might not want to run another function, but it is what it is.

    I’ve updated the above codepen with the solution to this: View Codepen

    //hiding a column or two
    var adaptivewidth = function () {
      if (window.innerWidth < 768) {
        $("#jqxgrid").jqxGrid("hidecolumn", "phone");
        $("#jqxgrid").jqxGrid("hidecolumn", "hireDate");
      } else {
        $("#jqxgrid").jqxGrid("showcolumn", "phone");
        $("#jqxgrid").jqxGrid("showcolumn", "hireDate");
      }
    };
    
    //allows the above function to run whether window is loaded or resized
    ["load", "resize"].forEach((e) =>
      window.addEventListener(e, adaptivewidth, false)
    );
    Setting hidecolumn property #122347

    admin
    Keymaster

    Hi millhorn,

    It is possible that in your localhost you call the hidecolumn before the Grid is initialized or your script is loaded after you call the method. Usually, if you use jQuery, make sure that hidecolumn is called within document.ready or within window.onload and after the Grid is created.

    Otherwise, there is no reason for the method to not work.

    Best regards,
    Peter Stoev

    jQWidgets Team
    https://www.jqwidgets.com/

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

You must be logged in to reply to this topic.