How to select Default value through Methods?
I have a question
- How to select value through another function for ejDropDownList?
HTML:
<div class="control">
<div class="ctrllabel">Select a bike</div>
<input type="text" id="bikeList" />
</div>
JavaScript:
<script type="text/javascript">
var target;
$(function () {
// declaration
BikeList = [
{ empid: "bk1", text: "Apache RTR" }, { empid: "bk2", text: "CBR 150-R" }, { empid: "bk3", text: "CBZ Xtreme" },
{ empid: "bk4", text: "Discover" }, { empid: "bk5", text: "Dazzler" }, { empid: "bk6", text: "Flame" },
{ empid: "bk7", text: "Fazzer" }, { empid: "bk8", text: "FZ-S" }, { empid: "bk9", text: "Pulsar" },
{ empid: "bk10", text: "Shine" }, { empid: "bk11", text: "R15" }, { empid: "bk12", text: "Unicorn" }
];
$('#bikeList').ejDropDownList({
dataSource: BikeList,
fields: { id: "empid", text: "text", value: "empid" }
});
// this code in another function
var dropDown = $("#bikeList").data("ejDropDownList");
dropDown.selectItemByValue("bk7") // doesn't work
dropDown.selectItemByText("Fazzer") // doesn't work
});
</script>
thanks in advance
Thanks for using Syncfusion products.
Query: How to select value through another function for ejDropDownList?
<script type="text/javascript"> var dropDownObj; $(function () { // declaration BikeList = [ { empid: "bk1", text: "Apache RTR" }, { empid: "bk2", text: "CBR 150-R" }, { empid: "bk3", text: "CBZ Xtreme" }, { empid: "bk4", text: "Discover" }, { empid: "bk5", text: "Dazzler" }, { empid: "bk6", text: "Flame" }, { empid: "bk7", text: "Fazzer" }, { empid: "bk8", text: "FZ-S" }, { empid: "bk9", text: "Pulsar" }, { empid: "bk10", text: "Shine" }, { empid: "bk11", text: "R15" }, { empid: "bk12", text: "Unicorn" } ]; $('#bikeList').ejDropDownList({ dataSource: BikeList, //'empid' attribute is mapped to the 'value' field. fields: { id: "empid", text: "text", value: "empid" } }); }); function setValue() { //Object for Dropdownlist is created dropDownObj = $("#bikeList").data("ejDropDownList"); //Set value to EJ Dropdownlist using public methods dropDownObj.setSelectedValue("bk7"); // Set value in drodownlist based on 'value' field. dropDownObj.setSelectedText("FZ-S"); // Set value in dropdownlist based on 'text' field. //Set value to EJ Dropdownlist using properties. dropDownObj.option("value", "bk7"); //Sets value to dropdownlist based on the field mapped to 'value' field. In case if 'value' field is not specified, value will be set to dropdownlist if the specified value matches the text of the dropdownlist items. dropDownObj.option("text", "Dazzler"); //Sets value to dropdownlist, if the text matches with text of dropdownlist items. } script> |
Regards,
HariKrishnan
- 1 Reply
- 2 Participants
-
ER Edgar Ricardez Peralta
- May 4, 2015 11:42 PM UTC
- May 5, 2015 01:37 PM UTC