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
newbiewebSr. Software EngineerAsked:
Who is Participating?
 
ZvonkoConnect With a Mentor Systems architectCommented:
You can call the checking function for every control but the response should not result in an Disply but deposit the message to a collection variable where you can check at given time whether error messages are there and format them accordingly.
0
 
newbiewebSr. Software EngineerAuthor Commented:
that sounds great but I do not know how to do a few things:

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.  
0
 
ZvonkoSystems architectCommented:
Show me your Ajax/jqGrid JavaScript source that you used last and I can extend it.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
newbiewebSr. Software EngineerAuthor Commented:
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>

Open in new window

0
 
newbiewebSr. Software EngineerAuthor Commented:
So, each one returns the same error message. That's the problem.
0
 
ZvonkoConnect With a Mentor Systems architectCommented:
Sorry but it is late for me.
The upper code are only formating attributes.
For client side you can define validation functions that extend the default valdition checking.
But I did not found the matching example where the callback function are defined.

I will try to find more tomorrow.

Good Night.
0
 
newbiewebSr. Software EngineerAuthor Commented:
Thank you.
0
 
newbiewebSr. Software EngineerAuthor Commented:
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:
http://www.experts-exchange.com/Programming/Languages/Scripting/AJAX/Q_27392121.html
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.