lundi 13 juin 2016

MVC Create Drop Down List with data attributes

I have a dynamic reports project which has a central Dictionary with the reportAttributes object having:

string dropDownValue, 
string dropDownText,
string datePickerToShow,
string setPeriod,
string setAmount

On the web page get two dates, one with a date picker and the other calculated as a set period either before or after the selected date with jQuery. For example if I show the right date picker, with 3 as the setAmount and month as the setPeriod would be the 3 months prior to(and including) the date selected in the date picker, likewise the left date picker would be the first date in the range setAmount x setPeriod. Also note both date pickers would be a fully custom range and no date pickers would be an 'all dates' range.

Once I have made a selection, I will click a button which will send in the date picker/calculated dates and the controller will get the data from a set of reused reports which is returned by jSon into a table which is formatted by the Datatables widget.

How would I set all 5 elements for each option in the drop down so that I can find the selected option and display the correct combination of date picker(s) and set the setDifference and setPeriod to a hidden element for calculating a set date.

I've seen a load of answers which provide an extra set parameter but I need a specific setting for each option. Is it best to add a variable to the dom(please confirm how this is done from the Model) and get jQuery to create the dropdown.

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire