Editor Select Field ID in Value

Editor Select Field ID in Value

simoncunsimoncun Posts: 16Questions: 5Answers: 0
edited June 2014 in Free community support

Apologies if this has been asked before, I couldn't find it in any of my searches.

I'm using the Datatables Editor extension to edit a nested object. This is what I'm trying to do -

My JSON pseudo looks like this -

data.DueDate: 26/06/2014
data.WorkStage.Id: 3
data.WorkStage.Name: Invoiced

I want to display in a table like so -

DueDate | WorkStage.Name

26/06/2014 | Invoiced

and edit the WorkStage.Name in a select drop down.

I dynamically populate the values in the select as -

{ label: "", name: "WorkStage.Name", type: "select", ipOpts: getWorkStageList() }

and

function getWorkStageList() {

            var workStages = new Array();   
                     
            workStages.push({ "label": "Quote", "value": "1" });
            workStages.push({ "label": "Deliver", "value": "2" });
            workStages.push({ "label": "Invoiced", "value": "3" });
        }

The issue I'm having is that when I click to edit the WorkStage.Name field the select list defaults to the first value and not the current WorkStage.Name. The select is choosing its selected option from the value and not the label, is there any way to get it to select the option where the label matches WorkStage.Name?

My JSON is a fair bit more complex than shown here and if I can get the ID of the child objects back rather than their names then it would save me a lot of database lookups when they save the data.

Answers

  • simoncunsimoncun Posts: 16Questions: 5Answers: 0

    I fixed it by adding data: "WorkStage.Id" in

    { label: "", name: "WorkStage.Name", data:"WorkStage.Id", type: "select", ipOpts: getWorkStageList() }

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    Hi,

    Good to hear you got this working as you wanted. Thanks for posting back!

    Allan

This discussion has been closed.