ExtJS Combo Assignment Default value

Source: Internet
Author: User

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.

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.