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
Getting value that we entered and change the editable attribute of a form
08/05/2013
07:24
Avatar
R_A_P
Member
Members
Forum Posts: 7
Member Since:
29/04/2013
sp_UserOfflineSmall Offline

i'm still new about this jquery thing so theres actually a dozen things that i wanna ask. but for now i wanna ask about this things

i have this code

jQuery("#VWWMODULE").jqGrid(
{
url:'loadstatic.php?q=2&t=CORE_VW_WMODULE',
datatype: "json",
mtype: "POST",
colNames:['Id', 'From Range', 'To Range'],
colModel:
[
{
name:'id',
index:'id',
width:7,
editable:true,
edittype:'text',
editrules:{required:true},
editoptions:{maxlength:7, size:7},
formoptions:{rowpos:1, elmprefix:' '},
key:true
},
{
name:'rangefrom',
index:'rangefrom',
width:7,
editable:true,
edittype:'text',
editrules:{required:true, number:true},
editoptions:{maxlength:7, size:7},
formoptions:{rowpos:6, elmprefix:' '}
},
{
name:'rangeto',
index:'rangeto',
width:7,
editable:true,
edittype:'text',
editrules:{required:true, number:true, custom:true, custom_func:frtid},
editoptions:{maxlength:7, size:7},
formoptions:{rowpos:7,elmprefix:' '}
}
]

i wanna ask this three things :

1. as you can see in the 'rangeto' i'm having a custom validation. this validation is simple actually. it just needs to check whether the value of 'rangeto' that we input is greater than the value of 'rangefrom'. now how can i get the value from 'rangefrom' so i can compare it with value from 'rangeto' in the custom validation function?

2. for my second question is about index 'id'. it used as a primary key for a table. so it shouldn't be changed when in editing mode. i'm saying when in add mode, a user can input it anyway he want. but once he submit it, the value can't be changed. in edit mode, the user can still see the 'id' value but he can't change it because it is ineditable. how can this be done?

3. how to make the custom validation function called just when in add mode? because my function will also gives error message even in edit mode when it should not be called

will you guys here please answer this three question? i've been asking this to other forum but seems there isn't any response there so i'm taking it here

09/05/2013
13:41
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Just curious - in wich forum do you asked this? I really want to know.

1. It depend. This is diffrent if you use form edit or inline editing.

For formediting this easy:

$("#rangefrom").val()

For inline edit ... - please look at doc editing. 🙂

2) You can use beforeShow form to make that field readonly in edit and editable in add mode.

There are a lot of posts regarding this, but if you go into the documentation here you will understand many thinks

3) Ther is no build in way.

I will tell you how to do, but use it carfully.

In form edit you can

$("#id_g").val()

if the value of this is equal to _empty then you are in add mode.

if( $("#id_g").val() == "_empty") {

// perform checking

// return result as of docs

} else  {

// return a value as everthing is ok - see docs

}

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.

10/05/2013
09:48
Avatar
R_A_P
Member
Members
Forum Posts: 7
Member Since:
29/04/2013
sp_UserOfflineSmall Offline

first of all, thanks for your response tony. i've been waiting for some answer for this 😀

1. yes, i am using form editing. well i've found the answer to this one just yesterday even before i see your answer. sorry for asking this simple thing. actually i've been reading the doc even before i post this question but maybe i'm missed it or i'm opening other part there so i couldn't find it in the first place

2. i had used beforeShowForm yesterday after i red the doc and i succesfully hid the form when it was in edit mode. but i still haven't managed to make it ineditable. because the catch is i had to show the 'id' to user so they know where they are and which data that they change. can you

3. i'm really lost with what you mean about this one. where should i put the code? and what is '#id_g'? did you mean in my case '#id'?

PS: it's not a real forum actually :p but i called it forum because it works like a forum imo :p and its called st***ov**fl** :p

10/05/2013
21:50
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

I answerd your question here. UPDATED part of the answer described why $("#id_g").val() is equal to "_empty" in Add dialog. The next picture clear it:

Image Enlarger

13/05/2013
08:10
Avatar
R_A_P
Member
Members
Forum Posts: 7
Member Since:
29/04/2013
sp_UserOfflineSmall Offline

thanks for the response oleg :)

i've read your response in stack also. answering your question there, i don't use inline editing or loadonce:true. and i do use reloadAfterSubmit. after your response and read the doc more, i can understand about what you mean with id_g. but i still don't understand where should i put the code which tony gave. is it before i put the custom validation? so i use it like this

if( $("#id_g").val() == "_empty")

{
// custom validation
}

but that doesn't work. so i don't know where should i put it.

about my second question, it is still unsolved. i did successfully hide it when in edit mode by using this code

beforeShowForm:function(formid)
{
$("#tr_id",formid).hide();
}

 but it only hides the id while what i need is for the user to still see the id. i've also used this code like what you answered here

 beforeShowForm:function(formid)
{
$("#tr_id",formid).attr('readonly','readonly');
 }

 but that doesn't change anything. in the edit mode the 'id' still can be change when it should be just a readonly.

 here is another part of my code if you to help you understand more

rowNum:15,
rowList:[15,30,45],
imgpath: gridimgpath,
autowidth: true,
pager: '#pagerVWWMODULE',
sortname: 'id',
viewrecords: true,
sortorder: "asc",
caption: "Create Module", 
editurl:"savewmodule.php",
height: "100%",
forceFit : true,
viewsortcols: [false,'vertical',true]
}).jqGrid('navGrid','#pagerVWWMODULE',
{view:true,edit:true,add:true,del:true},
{
width:500,
dataheight:250,
recreateForm:true,
reloadAfterSubmit:true,
jqModal:true,
closeOnEscape:true,
bottominfo:"Fields marked with (*) are required",
onInitializeForm:function(formid)
 {
 $("#tr_rangefrom",formid).show();
 $("#tr_rangeto",formid).show();

},

beforeShowForm:function(formid)
{
$("#tr_id",formid).attr('readonly','readonly');
}

},//edit
{
width:500,
dataheight:250,
recreateForm:false,
reloadAfterSubmit:true,
jqModal:true,
closeOnEscape:true,
bottominfo:"Fields marked with (*) are required",
onInitializeForm:function(formid)
 {

$("#tr_id",formid).show();
 $("#tr_rangefrom",formid).show();
 $("#tr_rangeto",formid).show();

}

},//add

did i miss something there?

i'm sorry if i'm asking too much, but this thing is really new for me. and though i've read the doc but there are still lots of unexplained things there

13/05/2013
09:30
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

I appended my answer.

13/05/2013
11:39
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

It ia always good idea to lok first into docs for the available events and when they occur.

Regards

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.

13/05/2013
12:04
Avatar
R_A_P
Member
Members
Forum Posts: 7
Member Since:
29/04/2013
sp_UserOfflineSmall Offline

okay i get the third one. thought it takes so much effort just to understand how to use the afterSubmit. but the second question is still unsolved. by using readonly:'readonly', both the add and edit mode will become readonly/ineditable, while what i want is to make it editable in add mode and ineditable/readonly in edit mode. i've tried that readonly yesterday after i red the doc. but that doesn't really solved the problem

btw, is there any other documentation about jqgrid besides trirand? cos i found it hard to understand. there are very much that is still unclear in the documentation there. so that makes a newbie user like me couldn't really understand what it meant to be and had to ask even for some simple things

13/05/2013
13:49
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

You get jqGrid for free with full open soure code. It has many features and it tries to hold backwards compatibilite with previous old versions and still introduce new features. If you have problems with understanding of documentation you can examine the source code of it.

Additionally to documentation you can find many code examples on stackoverflow.

As you could read before you can set readonly attribute on input filed inside of beforeShowForm. In the code example which you posted you do this in the wrong way. You try to make <tr> readonly ($("#tr_id",formid).attr('readonly','readonly');) instead of setting the attribute of <input> element ($("#id",formid).attr('readonly','readonly');). The callback onInitializeForm will be called before the form is created. So usage of $("#tr_rangefrom",formid).show(); inside is wrong.

15/05/2013
08:09
Avatar
R_A_P
Member
Members
Forum Posts: 7
Member Since:
29/04/2013
sp_UserOfflineSmall Offline

so that is my mistake. i thought those two are the same. would you kindly tell me what is the difference between "#tr_id" and "#id" in the actual use? what i know, the "tr_" part is just a prefix. but i don't really know that both are actually difference. by the way, thanks for helping me solved this :)  i'll keep learning about this jqgrid because even if it's doc is pretty poor in my opinion but it is actually an interesting thing and pretty easy to use (if you really understand how it works that is :P)

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
31 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