PDA

View Full Version : Making some items in combobox un-selectable



webfriend13
8 Oct 2012, 12:21 AM
HI All,

I have a combobox. In the combobox, I am first showing product type then the list of products (see the attached image).

39212

Requirement: I want to prevent user from selecting product category (Computer and Phone in this case). i know this can be done by using two combox, first combox will contain product category and second can be filled based on selected product category. But i want to use only one combobox.

Please provide your suggestions.

skirtle
8 Oct 2012, 5:22 AM
There are a number of ways to do this depending on the data. From what you've described I assume that your category names are just records in your store with some sort of flag set?

It's similar to something I had to do recently.

The way I solved it was to change the tpl for the boundlist. For the categories I outputted two entries rather than the usual one. One of those entries had the relevant CSS class to make it match the itemSelector but I also set it to have 'display: none' to ensure it wasn't visible. The other entry displayed the unselectable category header. There wasn't any trick to make it unselectable, it just didn't have the itemSelector class.

The reason why I used two entries is that the view would get confused if there wasn't a node matching the itemSelector but there isn't an easy way to make it unselectable other than hiding it.

webfriend13
8 Oct 2012, 6:13 AM
HI Skritle,

Yes, the categroty is another record in the store with a flag to indicate record is of type category. Thank you providing the solution. It would be a big help if you can share the code.