0

How to keep hidden columns in a grid when sorting?

asked 2020-04-09 15:42:48 +0800

softteam gravatar image softteam
130 1 8

updated 2020-04-10 15:50:16 +0800

cor3000 gravatar image cor3000
6280 2 7

Hello,

I have a grid with a menupop to select the hidden/visible columns. When I hide a column and then I click on the header to execute the sorting method, all the columns become visible. Is there any option to keep this columns hidden?

My code is something like this:

<grid id="GRIDCenso" mold="paging" pagingPosition="bottom" autopaging="true"
      span="false" sizedByContent="true" pageSize="10" width="100%" 
      xmlns:a="client/attribute" a:data-scrollable="false"
      model="@load(vm.beans)">
    <custom-attributes org.zkoss.zul.grid.autohidePaging="false"/>
    <custom-attributes org.zkoss.zul.image.preload="true"/>
    <columns menupopup="auto-keep" sizable="true">
        <column  width="40px" sclass="hiddenSelector"/>
        <column id="CLCama" sort="auto(cama)" hflex="min"/>
    </columns>

Thank you!

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-04-10 17:49:27 +0800

cor3000 gravatar image cor3000
6280 2 7

there's no such feature available out of the box. When using MVVM you store the UI state anyway in the view model e.g. keep the column-visibilities in a list of booleans, or a map (whatever you prefer), Or just keep a whole list of columnInfo objects containing getters for column information (label, visbilitiy, sortability ...)

You can then control the visibility using a @load-binding.

https://zkfiddle.org/sample/1n6hjff/2-keep-column-visiblity

The column menu can be customized (see fiddle above) at client side or a custom menu can be defined.

Then when sorting is triggered you can trigger the @load binding via notifyChange or as I do in the example using a conditional @load(..., after='sort') binding

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2020-04-09 15:42:48 +0800

Seen: 8 times

Last updated: Apr 10 '20

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More