Sorting of the content of a dropdown list using editable

Sorting of the content of a dropdown list using editable

NaGaNaGa Posts: 2Questions: 0Answers: 0
edited December 2012 in General
Hi !

I'm (desperatly) trying to sort 'correctly' the content of a drop down list used to modify a field.

Here's the code :

[code]
"aoColumns":
[
//famous field
{
sName: "empl_cli",
indicator: 'Enregistrement ...',
tooltip: 'Double clic pour modifier l\' emplacement',
loadtext: 'loading...',
type: 'select',
onblur: 'submit',
data: "{'105':'1AJ05','21':'1BA20','186':'1CC12','310':'1DA01B','61':'1DA02A','71':'1DA03B','287':'1DA04B','27':'1DA04C','345':'1DA06B','278':'1DA06C','240':'1DA07B','321':'1DA08A','102':'1DA08C','184':'1DA09A','305':'1DA10B','195':'1DA10C','297':'1DA11B','185':'1DA11C','239':'1DA12B','46':'1DA12C','254':'1DB01B','242':'1DB03A','247':'1DB04A','189':'1DB04B','415':'1DB05B','313':'1DB06A','140':'1DB07B','125':'1DB09B','371':'1DB10B','41':'1DB12A','60':'1DC01B','106':'1DC03A','31':'1DC04A','228':'1DC05A','360':'1DC05C','399':'1DC07B','388':'1DC07C','323':'1DC08B','221':'1DC09A','311':'1DC09C','56':'1DC10A','269':'1DC10C','288':'1DC11B','200':'1DC11C','429':'2AB04','358':'2AB08','181':'2AB09','182':'2AB10','154':'2AF04','491':'2AG03','499':'2AG11','501':'2AG13','503':'2AG14','511':'2AG21','514':'2AG23','538':'3ET11','539':'3ET12','540':'3ET13','541':'3ET14','542':'3ET15','481':'NP04B','482':'NP04B','486':'NP08B','487':'NP09B','477':'NP10A','488':'NP10B'}"
},

],
[/code]

The data is correctly sorted there, but it is 're-sorted' before showing in the drop down list, the first element showing is '21':'1BA20' which means that the sorting is done by the 1st value, the ID, while I want it to be sorted by the second value.

Any idea on how to perform that ?

Thanks alot !!!

Replies

  • NaGaNaGa Posts: 2Questions: 0Answers: 0
    no one ?
  • movilmovil Posts: 2Questions: 0Answers: 0
    edited May 2013
    I've been taking a look at this and if my guess it's right, this select is built by js/jquery.jeditable.js :

    LINE 491
    [code]
    content : function(data, settings, original) {

    console.log(data); // Here data is ordered by name

    /* If it is string assume it is json. */
    if (String == data.constructor) {
    eval ('var json = ' + data);

    console.log(json); // Here is ordered by ID

    } else {
    /* Otherwise assume it is a hash already. */
    var json = data;
    }
    for (var key in json) {
    if (!json.hasOwnProperty(key)) {
    continue;
    }
    if ('selected' == key) {
    continue;
    }
    var option = $('').val(key).append(json[key]);
    $('select', this).append(option);
    }

    /* Loop option again to set selected. IE needed this... */
    $('select', this).children().each(function() {
    if ($(this).val() == json['selected'] ||
    $(this).text() == $.trim(original.revert)) {
    $(this).attr('selected', 'selected');
    }
    });
    }
    [/code]

    So giving you this example you should be able to edit this and get the result you want. Good luck!
This discussion has been closed.