[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1533
  • Last Modified:

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
0
newbieweb
Asked:
newbieweb
  • 5
  • 3
2 Solutions
 
ZvonkoSystems 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
 
newbiewebAuthor 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
newbiewebAuthor 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
 
newbiewebAuthor Commented:
So, each one returns the same error message. That's the problem.
0
 
ZvonkoSystems 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
 
newbiewebAuthor Commented:
Thank you.
0
 
newbiewebAuthor 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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now