One final tricky bit is missing at this point. If you use any kind of real persistence layer, the id generation should be handled there. Even for an array store, you should use a different algorithm in reality to find the next valid id. Note that I'm using a very unsafe way of assigning a random id to the new supplier for this demo. $editor.dxTextBox("instance").option("value",Ĭ(newSupplier)) NewSupplier._id = parseInt(Math.random() * 1000000) So far, my supplier lookup column uses the array of suppliers as its data source directly, but now I introduce a new custom store for this purpose and bind this to the lookup column instead of the array:Ĭonst newSupplier = detailForm.option("formData") Once the form is in "creating new" mode, I need to persist the new supplier when the OK button is clicked, and make sure the grid is aware of its existence. In reality I would expect some additional logic here, for example to automatically suggest a new supplier number. I initialize the detail form with an empty object. The way I implement this, the switch is not reversible - for the quick-add feature I have in mind, this is acceptable, since the user can just hit Escape and bring up the popup a second time in case the process is started accidentally. SupplierPopupList.option("disabled", true) įorm.getEditor("search").option("disabled", true) Īs you can see, I disable all the UI elements that won't be used once the form is switched into its "creating new" state. there is no very easy way of getting hold of the button otherwise "this" is the button that triggered the event.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |