1. The wrong example
sexCombo.on("afterrender", function() {
sexCombo.setValue(sexStore.getAt(0).data.code);
});I don't know if it's possible in some cases, but my combo store is so assigned
<summary>/// View drop-down list of scopes///</summary>// <returns></returns> Public Jsonresult getscanscopelist () { list<scanscope> scopelst = new List<scanscope> {new ScanScope {Id = 0, Scanscope = "Not Completed"}, new Scanscope {id = 1, scanscope = "Completed"}, new Scanscope {id = 2, Scanscope = "All"}}; Return Json (Scopelst, jsonrequestbehavior.allowget); } <summary>/// View drop-down box DataSet entity//// </summary> public class Scanscope { public int Id; public string scanscope; }
In this case, if you do not first manually use the combo dropdown to select one, the Combo.getvalue () is "" "or RawValue, My is" "and" not completed. "
2. The right approach:
var Displayfield = Thisobj.down (' Displayfield '); var combo = Thisobj.down (' combobox[name=selectscanscope] '); var scanstore = Combo.getstore (); Scanstore.on (' Load ', function () {combo.setvalue (This.getat (0). Get (' Id ')); });
As for these statements, because my combo on the Tbar, I wrote in the Tbar BeforeRender event.