curiouswebster
asked on
Ajax/jqGrid error message displaying duplicates, using MVC
I have two field which together are validated together. But when they both fail, I get the error twice, as expected.
Each control calls a unique controller action, which returns JSON data. I tried combining them into one function but each field calls that Controller Action so each gets the error message. Then it's displayed two times.
I need to:
1) Find the HTML control where the error list items exist. Maybe I can code some jQuery to remove duplicate error messages.
OR
2) Find some other way to architect the AJAX.
Any ideas??
Ttanks
Or
2) Find a way to
Each control calls a unique controller action, which returns JSON data. I tried combining them into one function but each field calls that Controller Action so each gets the error message. Then it's displayed two times.
I need to:
1) Find the HTML control where the error list items exist. Maybe I can code some jQuery to remove duplicate error messages.
OR
2) Find some other way to architect the AJAX.
Any ideas??
Ttanks
Or
2) Find a way to
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Show me your Ajax/jqGrid JavaScript source that you used last and I can extend it.
ASKER
It's standard jqGrid validation
<text>
{ name: 'Volume', label: "Volume<br/>(µl)", sortable: false, width: 100, formatter: function (cellvalue, options, rowdata) {
return $.jgrid.format("<input type='text' id='Vol_{0}' name='samples[{0}].Vol' value='{1}' class='amt' tabindex='{2}' "
+ "data-val='true' data-val-required='Volume is required.' data-val-number='Must be a number.' "
+ "data-val-positive='Must be greater than zero.' "
+ "data-val-range-max='9999.99' data-val-range='Maximum value for the Volume field is 9999.99.' "
+ "data-val-regex-pattern='^[0-9]{1,8}(\.[0-9]{1,2})?$' data-val-regex='Max precision for the Volume field is 2 digits after the decimal point.' "
+ "data-val-remote-url='/Ajax/IsVolEnough' data-val-remote-additionalfields='SubmissionID,samples[{0}].Conc' data-val-remote='Provided Volume and Concentration are not enough' data-val-remote-type='POST' "
+ "/>", rowdata.key, cellvalue || '', rowdata.key*3+3);
}
},
{ name: 'Concentration', label: "Concentration<br/>(µmol/l)", sortable: false, width: 100, formatter: function (cellvalue, options, rowdata) {
return $.jgrid.format("<input type='text' id='Conc_{0}' name='samples[{0}].Conc' value='{1}' class='amt' tabindex='{2}' "
+ "data-val='true' data-val-required='Concentration is required.' data-val-number='Must be a number.' "
+ "data-val-positive='Please provide number greater than zero for the Concentration field.' "
+ "data-val-range-max='99.999' data-val-range='Maximum value for the Concentration field is 99.999.' "
+ "data-val-regex-pattern='^[0-9]{1,7}(\.[0-9]{1,3})?$' data-val-regex='Max precision for the Concentration field is 3 digits after the decimal point.' "
+ "data-val-remote-url='/Ajax/IsConcEnough' data-val-remote-additionalfields='SubmissionID,samples[{0}].Vol' data-val-remote='Provided Volume and Concentration are not enough' data-val-remote-type='POST' "
+ "/>", rowdata.key, cellvalue || '', rowdata.key*3+4);
}
},
</text>
ASKER
So, each one returns the same error message. That's the problem.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.
ASKER
I wil try to do this:
For client side you can define validation functions that extend the default valdition checking.
Also, I have another question here:
https://www.experts-exchange.com/questions/27392121/Need-functions-that-extend-the-default-validation-checking-for-jqGrid.html
For client side you can define validation functions that extend the default valdition checking.
Also, I have another question here:
https://www.experts-exchange.com/questions/27392121/Need-functions-that-extend-the-default-validation-checking-for-jqGrid.html
ASKER
You can call the checking function for every control -- that I can do
but the response should not result in an Disply -- do you mean do not assign a value for data-val-remote as I currently do? Otherwise I do not know how to prevent it from displaying. Please elaborate.
but deposit the message to a collection variable -- I would need to use Ajax to deposit it in the collection, right? Again I do not know how.
where you can check at given time whether error messages are there and format them accordingly.
Since mouse hovering over the jqGrid opens the message box, I do not know how to do that myself.