Forum



20:53

02/05/2011

OlegK said:
The first problem is: what you want to achive? The second: do you placed the code on the correct place? You should better describe the problem which you has more clear and post more code.
Best regards
Oleg
Hello, thanks for the correction.. here is my problem and what i want..
I want that when a user clicks on the add button on the grid, i want to feed some of the feilds in the add diaglog box with values from the grid. grid is display information that have a foreign key, so it means if the user wants to add new data i have to save the foreign of the record too. I hope you will understand what am driving at.
Thanks a lot
12:29

10/08/2009

Sorry, but I still not really understand what you want. If you have some foreign keys in the grid the key can be known only for the existing rows. In case of "Add" dialog a new data item or items will be created (probably on the server) after the submitting. Moreover it is absolutely unclear for me why some additional information should be shown for the user in the "Add" dialog. I could understand, that some additional information should be send to the server together with the request to add new item or some additional information (not only the id of new item) will be send back inside the server response on the "add" operation.
In general if it is really needed to display information, one can of course add any additional information to the "Add" or "Edit" dialog. If the information, which need be displayed, are saved in the hidden column it can be implemented very easy. It can be that what you need can be just implemented by definition of defaultValue property in the editoptions. I don't know. I have to few information.
The solution of the problem could be JavaScript code, but it is difficult to write something if you don't posted any code, if the column definitions are unknown, if it is not clear whether you implemented the grid as the local grid or as grid with datatype:'json' or 'xml' and so on.
So if you don't want to spend your and my time you should describe the problem more full und clear and post the current JavaScript where the jqGrid is used and clear mark the places in the code which work not like you as need.
Best regards
Oleg
13:26

02/05/2011

ok let me explain this way to make you understand ok.
I this tables in the database:
CREATE TABLE `brother` (
`brotherid` int(11) NOT NULL AUTO_INCREMENT,
`BirthPlace` varchar(30) DEFAULT NULL,
`Surname` varchar(30) DEFAULT NULL,
`Situation` varchar(10) DEFAULT NULL,
`Nationality` varchar(30) DEFAULT NULL,
`Country` varchar(30) DEFAULT NULL,
`State` varchar(30) DEFAULT NULL,
) PRIMARY KEY (`id`)
CREATE TABLE `changeprovince` (
`changeProvinceID` int(11) NOT NULL AUTO_INCREMENT,
`changebrotherid` int(11) DEFAULT NULL,
`dateTwo` varchar(15) DEFAULT NULL,
`toProvince` varchar(30) DEFAULT NULL,
`dateOne` varchar(15) DEFAULT NULL,
`fromProvince` varchar(30) DEFAULT NULL,
PRIMARY KEY (`changeProvinceID`),
KEY `FK_changeprovince` (`changebrotherid`),
CONSTRAINT `FK_changeprovince` FOREIGN KEY (`changebrotherid`) REFERENCES `brother` (`brotherid`) ON DELETE CASCADE
)
I have about 4 other tables that references BROTHER table
CHANGEPROVINCE table have been displayed in a grid and is a child table having a forieng key which is a primary in the BROTHER table.
Now my problem
when a user clicks on the add button on the CHANGEPROVINCE grid.. the add dialog opens. i want to be able to fetch one of the changebrotherid fields and insert it into the changebrotherid field in the add dialog box before the users saves.
I if dont do this mysql will generate an error
thanks
13:36

10/08/2009

Hello!
I asked you to post your current JavaScript code. Why you don't post it?
From the information which you posted it is not clear how you determine the changebrotherid on click of Add button of the changeprovince grid. Probably you display more as one grid on the page and get id of the selected row of the another grid (the grid with brothers). From the information which you posted it is still unclear why it would be interesting for the user to see the changebrotherid or any other id. It could be interesting only for the server. If the changeprovince grid has hidden changebrotherid field you can add some additional properties (see here) to send the changebrotherid to the server. If changebrotherid field is not inside of the changeprovince grid you can modify the postdata parameter of beforeSubmit, use editData paramer or use serializeEditData event handle.
So you have at least 4 possibility to send additional information to the server without to show any additional information to the user. The code used beforeShowForm, which you posted in your first post, shold aslo works if you use it corectly, but I need to see more code to say why your code fragment not work.
Your database design seems me also strange. Look at the table brother for example. It has brotherid column, which looks like id, but you use PRIMARY KEY (`id`) instead of PRIMARY KEY (`brotherid`). Then too many columns of the brother table you declare as nullable. At least Surname column and not only brotherid column should be declared with NOT NULL.
I don't know your original problem for which the database is created, but nevertheless the existence of the brother table seems me strange. I could more imagine person table having informations like Surname, BirthPlace and so on. The relative table whould include only two id refereces from the person table and the reference id from another level_of_relation table which assigns ids to relations like brother, husband, father and so on. In the case you will have less information duplicates and the information about brothers which is symmetric from the nature will be saved also in symmetric way.
Best regards
Oleg
23:52

10/08/2009

I agree that the thread describes very close problems as which you have. If I would wrote my personal opinion (suggestion) in the thread I would suggest just to save the id of the last selected row of the master grid in a variable. Then if the user click on the "Add" button of the "child" grid you will get the FK id (brotherid in your case) from the variable.
One more possibility is more native. If the user select a row in the master grid your should set the parameter of the URL from the child grid to get the corresponding data and trigger "reloadGrid". I would set postData to postData: {brotherid: parentId} in the child grid before reloaging of the grid. So the parentId will be already saved somewhere in the parameters of the child grid and you can get the value any time when you as need.
I am sure that you will solve the problem.
Best regards
Oleg
09:47

10/08/2009

How you can see from my status for example I am not a developer of jqGrid and not a moderator of the forum. I answer relative many question here and on the stackoverflow about the jqGrid. Nevertherless I have not enough time to create demos on demand. I have to make my main projects to earn money which we all need.
Best regards
Oleg
Most Users Ever Online: 715
Currently Online:
63 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66