Easyui drop-down box to get the value

Source: Internet
Author: User

The value of the Easyui drop-down box is the JSON format chestnut:

The wording of the front desk:

function Querydes () {        $ (' #des '). ComboBox ({             ' businessbaseinfo/querydes.action ',            Valuefield:' enmdatopt ',   // value            textField: ' enmdatdes '    / / what the foreground drop-down box displays          });     }

The URL gets the JSON format, the data here is in the background wrapped JSON format, can be directly obtained:

[    {        "enmdatdes": "Pig on behalf of the butcher",        "enmdatopt": "2001"    },    {        "enmdatdes ":" Hog Dealer ",        " enmdatopt ":" 2002 "    },    {        " enmdatdes ":" Live sheep Dealer "  ,        "enmdatopt": "2022"    },    {        "enmdatdes": "All",        " Enmdatopt ":" "    }]

There is also a background JSON does not conform to the rules, my practice is that the foreground parse JSON, and then repack the data such as:

{    "ErrorCode": 10000,    "ErrorMsg": "Operation succeeded",    "List": [        {            "Enmcnnam": "Flow node Type",            "Enmdatdes": "Slaughter Factory",            "Enmdatlen": "4",            "Enmdatopt": "0001",            "Enmennam": "NODETYPE",            "Enmno": "1",            "Sysid": "1000",            "Sysnam": "Meat dish system"        },        {            "Enmcnnam": "Flow node Type",            "Enmdatdes": "Supermarket",            "Enmdatlen": "4",            "Enmdatopt": "0004",            "Enmennam": "NODETYPE",            "Enmno": "11",            "Sysid": "1000",            "Sysnam": "Meat dish system"        },        {            "Enmcnnam": "Flow node Type",            "Enmdatdes": "Group consumption unit",            "Enmdatlen": "4",            "Enmdatopt": "0005",            "Enmennam": "NODETYPE",            "Enmno": "12",            "Sysid": "1000",            "Sysnam": "Meat dish system"        }    ]}

The foreground accepts JSON and parses, the foreground drop-down box data needs to be Enmdatdes and enmdatopt These two, then wraps these two :

     
   
var stuarrayobjs = [];function Querydes () {$.ajax ({URL:' Common/finddiclist?enmennam=nodetype ', DataType:"JSON", type:"POST", Success:function (data) {var obj=eval (data); for(Var i=0;i<obj.list.length;i++) {var stuarrayobj= {}; stuarrayobj["Enmdatdes"] =Obj.list[i].enmdatdes; stuarrayobj["Enmdatopt"] =obj.list[i].enmdatopt; Stuarrayobjs.push (Stuarrayobj); } //var teachcoursejsonstring = json.stringify (STUARRAYOBJS); Note this, the data for the dropdown box is not for this $(' #des1 '). ComboBox ({DATA:STUARRAYOBJS, Valuefield:' Enmdatopt ',//values to be passed back to the platformTextField: ' Enmdatdes '//what the foreground drop-down box displays }); } }); }

So it's done.

Easyui drop-down box to get the value

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.