Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get value different then description in options ? #20

Closed
GoogleCodeExporter opened this issue May 8, 2016 · 9 comments
Closed

Comments

@GoogleCodeExporter
Copy link

I need to get other values than the description in my select options

<option val="20142">My description</option>

any idea how to do this ?

Tnx
Rob

Original issue reported on code.google.com by rob...@gmail.com on 13 Jul 2011 at 10:40

@GoogleCodeExporter
Copy link
Author

I try to explain it a bit different:
I would like to be able to define the values and labels for the options:
{type: "select",values: ["val1","val2"],labels:["label1","Label2"]}
this way i can do a search for a certain value, but give it another name in the 
select dropdown.

in the columnfilter code is a loop to extract all the values from the aData 
array.:
   r += '<option value="' + aData[j] + '">' + aData[j] + '</option>';


I just can't figure out how i can get the labels in another array.

any idea is more then welcome.




Original comment by rob...@gmail.com on 15 Jul 2011 at 2:46

@GoogleCodeExporter
Copy link
Author

This functionality is not builtin, but the way I would handle it would be to do 
something along the lines of:
{ type: "select", options: [{'value': 'val1', 'label': 'label1'}, {'value': 
'val2', 'label': 'label2'}, {'value': 'val3', 'label': 'label3'}] }

and perhaps:
r += '<option value="' + aData[j].value + '">' + aData[j].label + '</option>';

This is untested code but should get you on the right path.

Original comment by gerard.d...@cwlake.com on 29 Jul 2011 at 2:53

@GoogleCodeExporter
Copy link
Author

On second thought, this would allow the code to be backwards compatible:

        if(typeof(aData[j]) != 'object')
                    r += '<option value="' + aData[j] + '">' + aData[j] + '</option>';
        }
        else {
            r += '<option value="' + aData[j].value + '">' + aData[j].label + '</option>';
        }

Again untested, but that should allow it to work with the old method as well as 
the method you are trying to use.

Original comment by gerard.d...@cwlake.com on 29 Jul 2011 at 3:01

@GoogleCodeExporter
Copy link
Author

I had a missing { in that if statement, it should have been:
            for (j = 0; j < iLen; j++) {
        if(typeof(aData[j]) != 'object') {
                    r += '<option value="' + aData[j] + '">' + aData[j] + '</option>';
        }
        else {
            r += '<option value="' + aData[j].value + '">' + aData[j].label + '</option>';
        }
            }

Still haven't tested that this actually works, but I have included it in my 
version and it no longer throws errors for simply being there.

Original comment by g.duerrm...@gmail.com on 29 Jul 2011 at 3:20

@GoogleCodeExporter
Copy link
Author

Well actually I ended up needing this functionality myself so I went ahead and 
finished the code. Basically what I provided earlier was almost working, I just 
hadn't followed everything through.

To ensure backwards compatibility, you would need to use this:
{ type: "select", values: [{'value': 'val1', 'label': 'label1'}, {'value': 
'val2', 'label': 'label2'}, {'value': 'val3', 'label': 'label3'}] }
(Note that we are keeping "values" instead of "options" as I had originally 
used. I think "options" is better named, but it breaks backwards compatibility.)

Then this change to the option looping, again ensuring backwards compatibility:
            for (j = 0; j < iLen; j++) {
        if(typeof(aData[j]) != 'object') {
                    r += '<option value="' + aData[j] + '">' + aData[j] + '</option>';
        }
        else {
            r += '<option value="' + aData[j].value + '">' + aData[j].label + '</option>';
        }
            }

I have tested this as working. Good luck!

Original comment by g.duerrm...@gmail.com on 20 Aug 2011 at 10:56

@GoogleCodeExporter
Copy link
Author

Original comment by joc...@gmail.com on 24 Sep 2011 at 11:03

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Hi,

This code is added in the version 1.2.4.

Thanks,
Jovan

Original comment by joc...@gmail.com on 25 Sep 2011 at 12:33

  • Changed state: Fixed
  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

Great, thank you for including that in!

Original comment by g.duerrm...@gmail.com on 25 Sep 2011 at 10:48

@GoogleCodeExporter
Copy link
Author

nice job!
Tnx



Rob

Original comment by rob...@gmail.com on 26 Sep 2011 at 5:04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant