/// <summary> /// Retrieves the HTML for the current field. /// </summary> /// <returns>An HTML String.</returns> public string GetSearchHTML() { string retval = ""; string fieldId = "data_" + IdData.ToString(); string validationFunction = ""; switch (Kind) { case Data.SIMPLE_TEXT: case Data.YES_NO: case Data.OPTIONS: case Data.CHECKBOX: case Data.TREE: case Data.EMAIL: retval = GetFieldHTML(); break; case Data.MULTI_TEXT: retval = DrawInput.InputTextField(fieldId, SearchValue, "", "", "", "", ""); break; case Data.INTEGER: case Data.FLOAT: NumberJSON numberJSON = JsonConvert.DeserializeObject <NumberJSON>(AuxValues); if ((numberJSON.from == numberJSON.to) && (numberJSON.to == 0)) { numberJSON.maxLength = "10"; } if (Kind == Data.FLOAT) { validationFunction = "validateFloat($(this), event);"; } else { validationFunction = "validateInt($(this), event);"; } retval = Text.Between + " "; retval += DrawInput.InputTextField(fieldId, SearchValue, numberJSON.maxLength, "", validationFunction, "width: 50px;", "title=\"" + Common.StrLang(Text.EnterValueBetweenXandY, numberJSON.from + "," + numberJSON.to) + "\" onKeyUp=\"" + validationFunction + "\""); retval += " " + Text.And + " "; retval += DrawInput.InputTextField(fieldId + "_aux", SearchValueAux, numberJSON.maxLength, "", validationFunction, "width: 50px;", "title=\"" + Common.StrLang(Text.EnterValueBetweenXandY, numberJSON.from + "," + numberJSON.to) + "\" onKeyUp=\"" + validationFunction + "\""); break; case Data.SLIDER: validationFunction = "validateInt($(this), event);"; retval = Text.Between + " "; retval += DrawInput.InputTextField(fieldId, SearchValue, "10", "", validationFunction, "width: 50px;", "onKeyUp=\"" + validationFunction + "\""); retval += " " + Text.And + " "; retval += DrawInput.InputTextField(fieldId + "_aux", SearchValueAux, "10", "", validationFunction, "width: 50px;", "onKeyUp=\"" + validationFunction + "\""); break; case Data.DATE: retval = Text.Between + " "; retval += DrawInput.InputTextField(fieldId, SearchValue, "", "datePicker", "", "width: 85px;", ""); retval += " " + Text.And + " "; retval += DrawInput.InputTextField(fieldId + "_aux", SearchValueAux, "", "datePicker", "", "width: 85px;", ""); break; default: break; } return(retval); }
/// <summary> /// Builds the HTML code for a given field. /// </summary> /// <returns>The HTML string of the field.</returns> public string GetFieldHTML() { string retval = ""; string fieldId = "data_" + IdData.ToString(); string validationFunction = ""; switch (Kind) { case Data.SIMPLE_TEXT: retval = DrawInput.InputTextField(fieldId, Value, "", "", "", "", ""); break; case Data.YES_NO: retval = DrawInput.InputSelect(fieldId, Value, Common.CSVToArray("," + Text.Yes + "," + Text.No), "", "", "", ""); break; case Data.OPTIONS: retval = DrawInput.InputSelect(fieldId, Value, Common.CSVToArray('|', "|" + AuxValues), "", "", "", ""); break; case Data.INTEGER: NumberJSON numberJSON = JsonConvert.DeserializeObject <NumberJSON>(AuxValues); if ((numberJSON.from == numberJSON.to) && (numberJSON.to == 0)) { validationFunction = "validateInt($(this), event);"; numberJSON.maxLength = "10"; } else { validationFunction = "validateInt($(this), event, " + numberJSON.from + ", " + numberJSON.to + ");"; } retval = DrawInput.InputTextField(fieldId, Value, numberJSON.maxLength, "", validationFunction, "width: 50px;", "title=\"" + Common.StrLang(Text.EnterValueBetweenXandY, numberJSON.from + "," + numberJSON.to) + "\" onKeyUp=\"validateInt($(this), event);\""); break; case Data.FLOAT: NumberJSON numberJSONf = JsonConvert.DeserializeObject <NumberJSON>(AuxValues); if ((numberJSONf.from == numberJSONf.to) && (numberJSONf.to == 0)) { validationFunction = "validateFloat($(this), event);"; numberJSONf.maxLength = "10"; } else { validationFunction = "validateFloat($(this), event, " + numberJSONf.from + ", " + numberJSONf.to + ");"; } retval = DrawInput.InputTextField(fieldId, Value, numberJSONf.maxLength, "", validationFunction, "width: 50px;", "title=\"" + Common.StrLang(Text.EnterValueBetweenXandY, numberJSONf.from + "," + numberJSONf.to) + "\" onKeyUp=\"validateFloat($(this), event);\""); break; case Data.DATE: retval = DrawInput.InputTextField(fieldId, Value, "", "datePicker", "", "width: 85px;", ""); break; case Data.CHECKBOX: retval = DrawInput.InputCheckbox(fieldId, Value, (Value == "1"), "", "", "", "onChange='toggleCheckbox($(this));'"); break; case Data.TREE: retval = DrawInput.InputHiddenField(fieldId, Value, "", ""); retval += "<div id='tree_" + fieldId + "'></div>"; retval += "<script language='JavaScript'>"; retval += "$('#tree_" + fieldId + "').treeSelectJSON({"; retval += " source: " + AuxValues + ","; retval += " target: '" + fieldId + "',"; retval += " defaultText: '- " + Common.SQSF(Text.Select) + " -',"; retval += " preselected: '" + Value + "'"; retval += "});"; retval += "</script>"; break; case Data.MULTI_TEXT: retval = DrawInput.InputTextArea(fieldId, Value, "4", "", "", "", "width: 100%;", ""); break; case Data.SLIDER: if (String.IsNullOrEmpty(Value)) { Value = "0"; } retval = DrawInput.InputHiddenField(fieldId, Value, "", ""); retval += "<div id='" + fieldId + "_slider'></div>"; retval += "<script language='JavaScript'>"; retval += "$('#" + fieldId + "_slider').slider({ value: " + Value + ", max: " + AuxValues + ", change: function() { $('#" + fieldId + "').val($('#" + fieldId + "_slider').slider('option', 'value')) }});"; retval += "</script>"; break; case Data.EMAIL: retval = DrawInput.InputTextField(fieldId, Value, "", "", "validateEmail($(this));", "", "title=\"" + Text.InvalidEmail + "\" placeholder=\"[email protected]\""); break; case Data.LABEL: retval = "<div align='center'>" + AuxValues + "</div>"; break; default: break; } return(retval); }