Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Is there a way to get Add or Edit as a varible when using the navigator?
31/03/2010
13:50
Avatar
fxlindau
SE
Member
Members
Forum Posts: 3
Member Since:
31/03/2010
sp_UserOfflineSmall Offline

I'm trying to perform a custum_funk validation on one filed during ADD.

But this function should not work the same way during EDIT.

Is there a way to tell if I'm performing an ADD or an EDIT to the javascript?

This is the line that sets the parameters for the edit on the field "fld_Email":

{name:'fld_Email', index:'fld_Email', editrules:{custom:true, custom_func:checkMail}, editable:true,editoptions:{readonly:false,size:'400px'}}

This is where the navigatorbuttons are defined:

{reloadAfterSubmit:true, closeAfterEdit:true, modal:true, width:300 }, // edit options
    {reloadAfterSubmit:true, closeAfterAdd:true, modal:true, width:300}, // add options

I just want to know if it is EDIT or ADD and send a variable to the function… is that possible?

Here ist the function I use for validation:

 

function checkMail(value){
    var a = '';
       $.ajax({
       type: "POST",
       async: false,
       url: "users_checkmail.php",
       data: {fld_Email:value},
       dataType: "HTML",
       error: function(){
           a = [false,"Could not contact the server!",""];
           },
       success: function(msg){
          if(msg == 1){
            a = [false,"You must set an e-mail!",""];  
          }else if(msg == 2){
            a = [false,"Your e-mail is not correct",""];      
          }else if(msg == 3){
            a = [false,"Your e-mail is allredy in the system",""];      
          }else if(msg == 4){
            a = [true,""];      
          }
       }
    });
    return a;
}

Best regards

Fredrik

01/04/2010
23:43
Avatar
fxlindau
SE
Member
Members
Forum Posts: 3
Member Since:
31/03/2010
sp_UserOfflineSmall Offline

sorry to do this but.. isn't there anyone who can point me in the right direction on this .. please...

03/04/2010
17:50
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

This is not documented, but.

1. When we create the form we set a id of the form like this  FrmGrid_ + the id of the grid

2. When we create a form we create a hidden column with a only td element with hidden input element with id = id_g. In this element we store the id of the edited row.

3. When we are in add mode this id is set to "_empty"

So short your code should look like this if your grid has id = mygrid.

function checkMail(value){

var mode = $("#id_g","#FrmGrid_mygrid").val();

if(mode == "_empty") {

// we are in add mode

} else {

// we are in edit mode

}

...

}

Best Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

04/04/2010
15:51
Avatar
fxlindau
SE
Member
Members
Forum Posts: 3
Member Since:
31/03/2010
sp_UserOfflineSmall Offline

Thanx Tony! Laugh

That did the trick!

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
29 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information