add optgroup label support for select

Questionsadd optgroup label support for select
andyvill.chile asked 4 years ago

hi dear.

 

is possible add oprgroup label in select columns??

 

example

 

<select>
<optgroup label=’Expenses’>
<option value=’42’>Accounting Fees</option>
<option value=’60’>Bank Fees</option>
<option value=’23’>Bank Service Charges</option>
<option value=’24’>Books and Publications</option>
<option value=’25’>Cash Discounts</option>
<option value=’43’>Rent</option>
</optgroup>
<optgroup label=’Income’>
<option value=’19’>Sales</option>
<option value=’20’>Services</option>
<option value=’21’>Interest Income</option>
<option value=’22’>Other Income</option>
</optgroup>
</select>

 

thanks

 

4 Answers
Abu Ghufran Staff answered 4 years ago

This is not supported in library now. However you can use dataUrl property which will call a php page that should return this select / optgroup html code and it will fill the dropdown values.

$col[“editoptions”][“dataUrl”] = “my-dropdown.php”;

In this case, you don’t need to set $col[“editoptions”][“value”] property.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Adrian answered 4 years ago

Hi Abu,

I use your idea for  add optgroup label but, on grid display that column (page_name) display nothing (on edit and add mode works perfect and I have data inserted correctly into table)

My code:

$col = array();
$col[“title”] = “Nume pagina”;
$col[“name”] = “page_name”;
$col[“width”] = “300”;
$col[“edittype”] = “select”;
$col[“formatter”] = “select”;
$col[“stype”] = “select”;
$col[“editoptions”][“dataUrl”] = “drepturi_page_dropdown_test.php”;
$col[“searchoptions”][“dataUrl”] = “drepturi_page_dropdown_test.php”;
$cols[] = $col;

and script drepturi_page_dropdown_test.php is a simple test like:

<select>
<optgroup label=’Test1′>
<option value=’test1_1′>Test1_1</option>
<option value=’test1_2′>Test1_2</option>
</optgroup>
<optgroup label=’Test2′>
<option value=’test2_1′>Test2_1</option>
<option value=’test2_2′>Test2_2</option>
<option value=’test2_3′>Test2_3</option>
</optgroup>
</select>

Please help!

Thanks!

View post on imgur.com

Abu Ghufran Staff answered 4 years ago

Hi,

I tested it further and you need to set $col[“editoptions”][“value”] property as well (when using formatter select)

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Adrian answered 4 years ago

Works perfect!

Thank you very much!

Your Answer

11 + 9 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?