DataTable Field Type and Complex Data for optionsPair Doesn't return value

DataTable Field Type and Complex Data for optionsPair Doesn't return value

ITAppData@HomeStreet.comITAppData@HomeStreet.com Posts: 31Questions: 6Answers: 1

I unfortunately can't link to the site itself because it's internal, but I've tested it out, and it appears the DataTable field type is not able to use a complex data point for it's optionsPair?

I had the following code:

        mainEditor = new $.fn.dataTable.Editor({
            ajax: "@Url.Action("GetAdjustments", "Adjustments")",
            table: "#adjustmentTable",
            fields: [
                { label: "Adjustment For: ", name: "adjustmentUser",  type: "datatable", optionsPair: {value: "People.UserName" }, config: { ajax: "@Url.Action("GetPeople", "People", new { noTerm = true })", columns: [{ title: "Name", data: "People.FullName" }, { title: "Role", data: "Role.Name" }] } },
                { label: "Adjustment Type: ", name: "typeOption", type: "radio", options: ["Bps", "Dollar"], def: "Dollar" },
                { label: "Bps: ", name: "BpsAmount", fieldInfo: "Enter as positive number to give a BPs bonus, and a negative number for a bps recovery" },
                { label: "Dollar Amount: ", name: "DollarAmount", fieldInfo: "Enter as positive number to give a dollar amount bonus, and a negative number for a dollar amount recovery." },
                { label: "Clawbackable?: ", name: "IsClawback", fieldInfo: "Recovery will be taken from subsequent months if not 100% fully recovered in current period in accord with HSB policy.", type: "checkbox", separator: "|", options: [{ label: '', value: 1 }] },
                { label: "Comments: ", name: "Comments", type: "textarea"}
            ]
        });

The data displayed in the DataTable field just fine however, when it got posted back the value for "adjustmentUser" was empty.

I created a new function to pull in less complex data while still returning the fields from the "People" table that I needed and called that instead, and the value posts back as expected.

I couldn't find anything in the documentation about it, so I don't know if it's a bug, or just something the DataTable field isn't designed to handle?

I can use more workaround for this scenario, but was curious going forward.

Thanks :smile:

Answers

  • allanallan Posts: 54,881Questions: 1Answers: 8,601 Site admin

    What version of Editor are you using? 2.0.5 added the ability to use nested data - from the release notes

    Updated: datatable will now work with nested data using Javascript dot notation

    Allan

  • ITAppData@HomeStreet.comITAppData@HomeStreet.com Posts: 31Questions: 6Answers: 1
    edited September 2

    Hi Allan,

    I'm using 2.0.5 currently. On .NET version.

    I changed the function it calls to use non-nested data and it started working as expected.

    Let me know what information I can share.

  • allanallan Posts: 54,881Questions: 1Answers: 8,601 Site admin

    A link to the page showing the issue would be great please.

    Allan

  • ITAppData@HomeStreet.comITAppData@HomeStreet.com Posts: 31Questions: 6Answers: 1

    Hey Allan,

    Thanks again for the response. Unfortunately the page is internal only and I can't give any access to it externally.

    I will try to put together a test link for it and send over some of my code if that may help early next week.

Sign In or Register to comment.