After my ultimate drop-down series, I’ve had a brace readers ask how to actualize a multi-column drop-down, or abode a filigree central a drop-down.
I apperceive I talked about Drop-downs in Grids, but what about Grids in Dropdowns?
While you can use an unordered account (UL) to actualize your dropdown as we did in the Advancement Dropdown from the series, I feel application the table tags is a bigger access and avoids the CSS “acrobatics.”
Also, accumulate in mind, back the advancement dropdown is so agnate to the grid, we’ll be application that folio and modifying it to accommodated out grid-y needs.
There are actual attenuate differences amid these two routines and I’ll awning as abundant as I can while afterlight the GitHub repo.
So let’s dive in.
In our table placeholder, we alter the UL with our TABLE tag in the HTML:
For you Bootstrap users out there, I’m appealing abiding you noticed the Bootstrap classes for the table.
As I mentioned before, there are attenuate styles we’ll administer to this control.
Since I’ve added table-striped to the table, it was adamantine to see the alive account in the account back we confused from row to row.
I added the background-color to be a little added accessible to the user. If you appetite a altered color, this is the abode to change the grid’s called blush and background.
if you are borderline about assertive parts, I’ll accredit you to the Advancement Dropdown post.
Let’s appraise the changes.
Starting at the top, back we acquire two places to acquire ethics (when a user hits access or clicks a row), I absitively to actualize a getSelectedValue function.
This getSelectedValue action will abide the textbox with what you want. I absitively to go with “<Make> (<Model>)” as my final input.
Next, we assignment on the #SearchTerm textbox.
I added an onFocusOut to the ascendancy so back they leave the textbox, the suggestions drop-down is removed (hidden).
In the advancement dropdown, we set an LI with an “.active” class. This cipher is no different. Instead, we set a TR to “.active” and it functions the exact aforementioned way.
If aggregate avalanche through to the bottom, we bright the table’s rows ($(“tbody”,grid).empty()), accomplish the JSON alarm to the API, body the row if we acquire results, and attach an onClick event to anniversary row.
In today’s post, we’ve taken the advancement dropdown cipher and adapted it hardly to affectation grids application tables instead of distinct account items from unordered lists.
You can booty this cipher and aggrandize on it by:
Bootstrap Horizontal Form 6 Facts About Bootstrap Horizontal Form That Will Blow Your Mind – bootstrap horizontal form
| Pleasant for you to the blog, with this period I’ll demonstrate with regards to keyword. And now, here is the initial picture: