jQWidgets Forums

jQuery UI Widgets Forums Grid hide/show many columns

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 10 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • hide/show many columns #59638

    aldo86
    Participant

    HI,
    I’ve to show/hide many columns at the same time. So I use ‘hidecolumn’/’showcolumn’ but it takes a lot of time (around 10 sec for 30 col).
    This is my code:

    if($(this).get(0).checked == true){
        			
        			$.each(columnsH,function(k,v){
        				if (jQuery.inArray(v.text, difference)!=-1) {
        					$('#jqxgrid').jqxGrid('hidecolumn', v.datafield);
        				}
        			});
        			
        		}else{
        			$.each(columnsH,function(k,v){
        				if (jQuery.inArray(v.text, difference)!=-1) {
        					$('#jqxgrid').jqxGrid('showcolumn', v.datafield);
        				}
        			});
        			
        		} 

    Is there a way to do it faster? For example exist a function to hide a collection of datafield in one time?

    Best Regards

    hide/show many columns #59647

    Peter Stoev
    Keymaster

    Hi aldo86,

    You can use the Grid’s beginupdate, endupdate methods.

    
    $("#jqxgrid").jqxGrid('beginupdate');
                        $("#jqxgrid").jqxGrid('showcolumn', "col1");
                        $("#jqxgrid").jqxGrid('showcolumn', "col2");
                        $("#jqxgrid").jqxGrid('showcolumn', "col3");
                        $("#jqxgrid").jqxGrid('showcolumn', "col4");
                        $("#jqxgrid").jqxGrid('showcolumn', "col5");
          $("#jqxgrid").jqxGrid('endupdate');
    

    Best Regards,
    Peter Stoev

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

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

You must be logged in to reply to this topic.