ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
How to hide/show some columns of grid depending on textbox value ?
Title:
B
I
{code}
?
My Grid has columns id | name | passport_id and I have two textboxes - name_search - passport_id_search when I click search button I want to reload Grid and Show all col ---> id | name | passport_id ---> if passport_id_search have value Show only col ---> id | name ---> if passport_id_search have no value How I can ?
Save Changes
Cancel
nutfergie
asked at 04 Jan 2018
Answers
B
I
{code}
?
to make it more generic instead of looking at textbox value, I would look at the passportId value in the controller (grid url) new GridModelBuilder<Lunch>(list, g) { ... Tag = new { HidePid = string.IsNullOrEmpty(passportId) } }.Build()); and in the view give the passport column an id `Column { Id = "PassId"` , and add this js on document ready var grid = $('#Grid1'); grid.on('awebfren', function(){ var o = grid.data('o'); var cols = o.columns; var hide = o.lrs.tag.HidePid; for(var i= 0; i < cols.length; i++){ var col = cols[i]; if(col.I == 'PassId') col.Hid = hide; } });
Save Changes
Cancel
Omu
answered at 04 Jan 2018
I wonder use o.lrs o object where come from ???
at 06 Jan 2018
nutfergie
I've corrected my answer
at 06 Jan 2018
Omu
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