Drop Down Populated by SQL Server Using Editor and Server side
Drop Down Populated by SQL Server Using Editor and Server side
tarbeiter
Posts: 2Questions: 0Answers: 0
Hello
I have a form in Datatables that I would like to populate some of the select boxes with data from the SQL server instead of static entries. I'm not too far from the answer but keep getting tripped up somewhere.... I would like the EOL_Tracker.Application to be the drop down populated by all found values (not concerned with dynamic etc). Thanks in advance.
My editor entry from the JS
editor = new $.fn.dataTable.Editor( {
ajax: "actions/EOLTrackerActions.php",
table: "#display",
oncomplete: 'close',
onreturn: 'submit',
fields: [
{label: "Device Name:",name:"EOL_Tracker.Device_Name",type:"text"},
{label: "Status",name:"EOL_Tracker.Status",type:"select",
options:[
{label:"Active",value:"Active"},
{label:"Decommissioned",value:"Decommissioned"},
{label:"Duplicate",value:"Duplicate"},
{label:"Upgraded",value:"Upgraded"}
]},
{label: "Application:",name: "EOL_Tracker.Application",type:"select"},
{label: "Security Plan #:",name:"EOL_Tracker.Security_Plan",type:"text"},
{label: "Subsystem:",name:"EOL_Tracker.Sub_System",type:"text"},
{label: "Organization:",name:"EOL_Tracker.Org_Tag",type:"text"},
{label: "Planned Correction:",name:"EOL_Tracker.Planned_Decom_Date",type:"date"},
{label: "Actual Correction:",name:"EOL_Tracker.Actual_Decom_Date",type:"date"},
{label: "RISCS POAM:",name:"EOL_Tracker.RISCS_POAM",type:"text"},
{label: "RISCS AR:",name:"EOL_Tracker.RISCS_AR",type:"text"},
{label: "Internet Facing:",name:"EOL_Tracker.Inet_Facing",type:"text"},
{label: "Registered In:",name:"EOL_Tracker.Reg_in",type:"select",
options:[
{label:"KACE Agent",value:"KACE Agent"},
{label:"NMI",value:"NMI}"},
{label:"Not in EDW",value:"Not in ED"}
]
},
{label: "FIPS 199 Category:",name:"EOL_Tracker.FIPS_199",type:"select",
options:[
{label:"High",value:"High"},
{label:"Medium",value:"Medium"},
{label:"Low",value:"Low"}
]},
{label:"Risk Mitigation Plan:",name:"EOL_Tracker.Risk_Mit",type:"textarea"},
{label:"Actual Remediation Action:",name:"EOL_Tracker.Close_Action",type:"textarea"}
]
});
And the Actions Page
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'EOL_Tracker','EOL_ID')
->fields(
Field::inst('EOL_Tracker.EOL_ID' ),
Field::inst('EOL_Tracker.Application' ),
Field::inst('EOL_Tracker.Application_Imp' ),
Field::inst('EOL_Tracker.AppVersion'),
Field::inst('EOL_Tracker.DeviceName'),
Field::inst('EOL_Tracker.Status'),
Field::inst('EOL_Tracker.SecurityPlan'),
Field::inst('EOL_Tracker.SecurityPlanName'),
Field::inst('EOL_Tracker.SubSystem'),
Field::inst('EOL_Tracker.ORGTag'),
Field::inst('EOL_Tracker.POAM_Num'),
Field::inst('EOL_Tracker.POAM_SchedDate'),
Field::inst('EOL_Tracker.POAM_Complete'),
Field::inst('EOL_Tracker.POAM_CreatITSC'),
Field::inst('EOL_Tracker.AR_Num'),
Field::inst('EOL_Tracker.AR_Complete'),
Field::inst('EOL_Tracker.Planned_Decom_Date'),
Field::inst('EOL_Tracker.Actual_Decom_Date'),
Field::inst('EOL_Tracker.Inet_Facing'),
Field::inst('EOL_Tracker.IPAddress'),
Field::inst('EOL_Tracker.FIPS_199'),
Field::inst('EOL_Tracker.RISK_Mit'),
Field::inst('EOL_Tracker.Close_Action'),
Field::inst('EOL_Tracker.Reg_in'),
Field::inst('EOL_Tracker.OCIO_Report'),
Field::inst('EOL_Tracker.ECN'),
Field::inst('EOL_Tracker.CustComments'),
Field::inst('EOL_Tracker.ITB_Comments')
)
->process( $_POST )
->json();
This discussion has been closed.
Replies
Hi,
Is it basically something like this example that you are looking for?
Does your list of options for the
select
come from a joined database table? If so, have a read over this section of the manual which explains how to do that in detail. Feel free to come back with any questions about it!Allan
Allan
Thanks a ton your first link was exactly what I needed, it lifted the mental block I was having.
~Tim
Allan,
I have a couple of follow-up questions if you're still monitoring this thread. I'm looking at purchasing a license for Editor.
Is it possible to have this type: "select" dropdown box to display the current database field content as well as display other options? For example, I have a job assigned to a specific press within the "machine" column for a row in the db. When my user choses to Edit the record using the Datatable can I have the Editor pop-up dialog box display the current machine while presenting other machines in the list so that a different machine can be assigned?
Is it possible to style the select dropdown to look like the other fields in the Editor pop-up dialog?
Thank you.
Yes.
Sort of. This is more of a CSS issue rather than Editor itself -
select
elements are notoriously difficult to style. There are a number of SO threads on the topic - for example.Allan