ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Close groups and disable paging dynamically.
Title:
B
I
{code}
?
Hello, when i group by column with api: $('#@gridId').data('api').load({ group: ['columnname']}); I would like to disable paging for grid and close all groups except first. Attempts to use: $('#@gridId').data('api').load({ group: ['columnname'], params: {Paging: false}}); give no result. Thank You.
Save Changes
Cancel
Vladimir Kerzhentsev
asked at 06 Sep 2019
Answers
B
I
{code}
?
here's what you can do, add a parameter to your action, example: public ActionResult GetItems(GridParams g, ..., string cmd) and set the `PageSize` to max when this parameter has value: var list = Db.Lunches... if (cmd == "g1") { g.PageSize = list.Count(); } for collapsing we'll need to set the `GridModelBuilder.MakeHeader` var firstGroup = true; return Json(new GridModelBuilder<Lunch>(list, g) { ... MakeHeader = gr => { // get first item in the group var first = gr.Items.First(); // get the grouped column value(s) for the first item var val = string.Join(" ", AweUtil.GetColumnValue(gr.Column, first).Select(o => o.ToString())); var collapsed = !firstGroup && cmd == "g1"; firstGroup = false; return new GroupHeader { Content = string.Format("{0} : {1}", gr.Header, val), Collapsed = collapsed }; } }.Build()); and you can call the api like this: $('#Grid1').data('api').load({ group: ['Person'], oparams: { cmd: 'g1' } }) note I'm using `oparams` (one time) with params the `cmd` will persist in the subsequent calls
Save Changes
Cancel
Omu
answered at 06 Sep 2019
Thank You very much! Work like it should.
at 06 Sep 2019
Vladimir Kerzhentsev
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK