Hello!
I have an igGrid with updating feature.
I can not validate the value that use entered.
On last year. I used Infragistics 14.2 and it work fine but now I upgrated to 15.2 and it's not working
Here is my code:
@(Html.Infragistics() _.Grid(Of TPG.Position.Models.tbl_PG_CostOfFunds_Ts) _.ID("grdCostOfFunds") _.Width("100%") _.AutoGenerateColumns(False) _.AutoGenerateLayouts(False) _.AutofitLastColumn(True) _.EnableUTCDates(False) _.RenderCheckboxes(True) _.PrimaryKey("lCostOfFund_ID") _.AutoCommit(True) _.Columns(Sub(column)column.For(Function(x) x.lCostOfFund_ID).Hidden(True)column.For(Function(x) x.lPositionID).Hidden(True)column.For(Function(x) x.dtEffectiveDate).DataType("date").Format("MM/dd/yyyy").Width(100)column.For(Function(x) x.dblCostOfFund).DataType("number").Format("#,###,##0.000000").Width(200)column.For(Function(x) x.dblSpread).DataType("number").Format("#,###,##0.000000").Width(190)End Sub) _.Features(Sub(feature)feature.Updating.ColumnSettings(Sub(cs)
cs.ColumnSetting.ColumnKey("lPositionID").DefaultValue(Model.psintID)cs.ColumnSetting.ColumnKey("dtEffectiveDate").EditorType(ColumnEditorType.DatePicker).Required(True).EditorOptions("validatorOptions: { onblur: true, keepFocus: 'once', checkValue: validategrd_CostOfFunds}")cs.ColumnSetting.ColumnKey("dblCostOfFund").EditorType(ColumnEditorType.Numeric).Required(False)cs.ColumnSetting.ColumnKey("dblSpread").EditorType(ColumnEditorType.Numeric).Required(False)End Sub)feature.Sorting()feature.Filtering()feature.Resizing()feature.Responsive()End Sub) _.DataSourceUrl(Url.Action("GetDataForCostOfFunds", "Position", New With {.id = Model.psintID})) _.UpdateUrl((Url.Action("SaveGridCostOfFunds", "Position", New With {.id = Model.psintID}))) _.DataBind() _.Render())
<script type="text/javascript">
function validategrd_CostOfFunds(evt, ui) {var value = ui.value;var rows = $("#grdCostOfFunds").igGrid("rows");for (var i = 0; i < rows.length; i++) {var currentRow = rows[i];var currentValue = new Date(currentRow.cells[0].innerText);if (dates.IsEqualDate(value, currentValue) && $(currentRow).find(".ui-iggrid-editingcell").length == 0) {ui.message = "Duplicate Effective date.";return false;}}return true;}
</script>
i tried your method but i can't focus the pointer on the editor and alway show the error message if user didn't resolve the error
Thanks you very much!
Hello Cuong,
After further testing it seems that there is no ui.message argument available on igValidator 'validating' event. I logged an internal documentation bug about it. Instead you can move your code in 'validated' event, where ui.message argument is available. I'm attaching a sample with similar scenario for your reference. If you have any further questions, please let me know.
Regards,
Tsanna
Hello Tsanna,
I saw this reference. And I changed the 'checkValue' event to 'validating'. Then, in the error case I set ui.message = 'my message'.
But
The message could not shown. It is only show the require message.
And Then. I re-enter value to the editor.After that, I recieve the previous error message which I had set in the previous time.
I don't know how to fix it.
Here is my code!
cs.ColumnSetting.ColumnKey("dtEffectiveDate").EditorType(ColumnEditorType.DatePicker).Required(True).EditorOptions("validatorOptions: { onblur: true, keepFocus: 'once', validating: validategrd_CostOfFunds}")
<script>
function validategrd_CostOfFunds(evt, ui) {var value = ui.value;var rows = $("#grdCostOfFunds").igGrid("rows");for (var i = 0; i < rows.length; i++) {var currentRow = rows[i];var currentValue = new Date(currentRow.cells[0].innerText);if (dates.IsEqualDate(value, currentValue) && $(currentRow).find(".ui-iggrid-editingcell").length == 0) { ui.message = "Duplicate Effective date."; return false;}}return true;}
Please note that the editors validatorOptions are based on options supported by igValidator widget. Since v15.2 the igValidator API has been changed and now it provides the following options and events:
- options: http://help.infragistics.com/jQuery/2015.2/ui.igvalidator#options
- events: http://help.infragistics.com/jQuery/2015.2/ui.igvalidator#events
So if you want to apply validation to your editor column, you should use the available options exposed in the above mentioned links. If you need further assistance, please let me know.