Easyui ComboBox drop-down box The default initial value is NULL, the following is the way to initialize the default value after loading the data remotely, and to keep the value in the top of the drop-down box.
The current requirement is to add the "All Databases" field at the time of initialization, and at the drop-down, the "all Databases" is at the top of the line.
The effect of initialization is as follows:
The following drop-down effects are as follows:
Implementation method:
The Easyui ComboBox has a loader property, and the Easyui API describes the loader attribute as follows:
The Easyui ComboBox has a onloadsuccess event, and the Easyui API describes the Onloadsuccess event as follows:
The implementation method is to utilize the loader attribute and onloadsuccess event of Easyui.
The complete code looks like this (please focus on the key code, the part that is highlighted in red):
<input id= "DBName" name= "DBName" class= "Easyui-combobox" style= "width:200px"Data-options= "Valuefield: ' dbname ', TextField: ' dbname ', Editable:false,loader:function (param,success,error) {$.ajax ({url: ' ${pagecontext.request.contextpath}/rds/rds_findrdsdatabase S.action?dbinstanceid=${param.dbinstanceid} ', DataType: ' JSON ', Success:function (data) {Data.rows.unshift ({dbname: ', dbname: ' All Databases '}); success (data.rows);//loader Success} }); },Onloadsuccess:function () {$ (' #dBName '). ComboBox (' SetValue ', ' all databases '); } "/>
The above method Unshift () adds one or more elements to the head of the array, and then moves the existing elements to a larger position of the subscript to make room, which returns the new length of the array.
Easyui ComboBox drop-down box initializes default values and methods that keep the value displayed all the time