Need to set field value to column contents. Returns [object object] why?

Need to set field value to column contents. Returns [object object] why?

nicoledramirez@hotmail.comnicoledramirez@hotmail.com Posts: 60Questions: 14Answers: 2

editor.on('initEdit initCreate', function () {
editor.field('cdi_mileage.cdi_details_id').set({ columns: 5 });

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    What is the cdi_mileage.cdi_details_id field type? Does it expect an object as the value to set?

    Allan

  • nicoledramirez@hotmail.comnicoledramirez@hotmail.com Posts: 60Questions: 14Answers: 2

    It's a field that I want to set to the contents of column 5 after a link is clicked on.

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Is it a text input field? Or something else? None of the built in field types expect an object to be passed in.

    I'm not certain without being able to see the page, but I suspect you just want to do: ...set( 5 );.

    Allan

  • nicoledramirez@hotmail.comnicoledramirez@hotmail.com Posts: 60Questions: 14Answers: 2

    Hi Again Alan!
    Yes it is a text input field.
    Doing .set(5) only puts the value of 5 in the text field. But what I am looking for is to put the value of column #5 in the table called Example into the input field cdi_mileage.cdi_details.id. Since I can't open the site to view, I am attaching a screen shot of what I see to better explain. Where the value says 5 right now (text field labeled CDI), it should really say 135583 because that is what is in column #5.
    Thanks for all your help! :)

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Could you run the DataTables debugger on your table please? I'd like to see the structure of the table.

    It should be that if the table is using cdi_mileage.cdi_details.id for the column data (columns.data) and Editor's field name (fields.name) matches that, the field's value would automatically be populated.

    Allan

  • nicoledramirez@hotmail.comnicoledramirez@hotmail.com Posts: 60Questions: 14Answers: 2

    The debugger doesn't appear to work for me. I load my table and then hit the button in my favorites but it just goes back to DataTables debugger...?

  • nicoledramirez@hotmail.comnicoledramirez@hotmail.com Posts: 60Questions: 14Answers: 2

    And I don't think that is the case because it is like the render is wrong someplace but I am just not sure how to make it right. Because if I reference the column name instead of 5, it comes back with [object Object]. So it is like it just can't define the value. I am just not 100% sure how the structure is being defined in datatables.

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    If the debugger isn't working for you, I'd really need a link to the page showing the problem so I can try to debug it.

    Because if I reference the column name instead of 5, it comes back with [object Object].

    You shouldn't need to reference the column name in Editor at all. You use fields.name to reference the data point that Editor should edit - but you should never need to tell it explicitly what column that data is in.

    Allan

  • nicoledramirez@hotmail.comnicoledramirez@hotmail.com Posts: 60Questions: 14Answers: 2
    Answer ✓

    Resolved this issue. Can close.

This discussion has been closed.