Ticket T457525
Visible to All Users

How to implement cascading drop-down editors in dxForm

created 8 years ago

[DevExpress Support Team: CLONED FROM T456218: dxDataGrid - Cascaded dropdown editors]
I still don't get it.

Let say, I have two dropdowns for "Project" & "Worker"

there are Project A and B. Project A has workers X, Y, Z. Project B has workers K,L,M, N.

When I choose Project A. Only workers X, Y, Z comes out in the dropdown "Worker".

How to implement this using dxForm ?

Here is my code in PHP & Java script :

JavaScript
  $(function ()         {     var projects = <?= $projects ?>;     var workers = <?= $workers ?>; $("#form").dxForm({     items: [         {             dataField: "Project",             editorType: "dxSelectBox",             editorOptions: {                 items: projects,                 displayExpr: "name",                 valueExpr: "id",             },             validationRules: [{                 type: "required",                 message: "Project is required"             }]         },         {             dataField: "Worker",             editorType: "dxSelectBox",             editorOptions: {                 items: workers,                 displayExpr: "name",                 valueExpr: "id",             },             validationRules: [{                 type: "required",                 message: "Worker is required"             }]         },

Answers approved by DevExpress Support

created 8 years ago

Hi,

I created a simple example illustrating how to change the second editor's data in the onValueChanged handler of the first editor.
Please review it and let us know your results.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.