Field Set Value from a different location
Field Set Value from a different location
nicoledramirez@hotmail.com
Posts: 60Questions: 14Answers: 2
This calls out a computer name:
var url = "/api/cdi_master/GetLogin";
$.get(url, null, function (data) {
$("#rData").val(data);
});
Right now it passes to a location on my page but I would also like it to pass the value to User field in the editor below.
This is my editor code:
var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function () {
editor = new $.fn.dataTable.Editor({
"ajax": "/api/cdi_master",
"table": "#example",
"fields": [
{
label: "<div background-color=#004d99; layer-background-color:#004d99><b>Show Form Action:</b></font>",
name: "options",
type: "radio",
options: [ "Billing Status Only", "Add Reconciliation" ],
def: "Billing Status Only"
},
{
label: "Billing Status:",
name: "cdi_details.billing_status",
value: "cdi_billing_status.id",
type: "radio"
},
{ label: "Audit Status",
name: "cdi_details.audit_status",
value: "cdi_audit_status.id",
type: "radio"
},
{
label: "User",
name: "User"
},
{
label: "Insurance:",
name: "cdi_details.insurance_id",
value: "cdi_insurance.id",
type: "select"
},
{
label: "Amount Billed",
name: "cdi_details.amount_billed",
def: "0.00"
},
{
label: "Amount Received",
name: "cdi_details.amount_received",
def: "0.00"
},
{
label: "Date Mailed",
name: "cdi_details.date_mailed",
type: "date",
def: "00/00/0000"
},
{
label: "Optional Comments",
name: "cdi_details.comment",
type: "textarea"
},
]
});
editor.dependent('options', function (val) {
return val === 'Add Reconciliation' ?
{ show: ['cdi_details.insurance_id', 'cdi_details.amount_billed', 'cdi_details.amount_received', 'cdi_details.date_mailed'] } :
{ hide: ['cdi_details.insurance_id', 'cdi_details.amount_billed', 'cdi_details.amount_received', 'cdi_details.date_mailed'] }
;
} );
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This discussion has been closed.
Answers
Hi,
It sounds like you just want to add
editor.set( 'User' ).val( data );
in your$.get
callback (assuming that function is executed while the edit view is open).Allan
I did try that (probably should have posted the correct syntax, sorry about that). But I think I am a little lost as to exactly where to place the statement while the edit view is open?
I guess the key question is, at what point is your
$.get
executed to get the user id? Is it at page load? In which case save the value into a variable and use theinitCreate
andinitEdit
events to set the field's value:Allan
It is executed based on the user clicking on the reconcile link:
var table = $('#example').DataTable( {
ajax: "/api/cdi_master",
deferRender: "true",
"columns": [
Unable to get property 'get' of undefined or null reference
Solved my own problem and posting for whoever needs something like this. Using editor.set will not work. The following does work :
Thanks for posting back with your solution.
Allan