Create new button

Talk about any other operations you need to implement: additions, updates etc.

Moderator: alexandrleonenko

dednrgrid
Junior
Junior
Posts: 16
Joined: Jun 1st, '11, 11:00

Create new button

Postby dednrgrid » Jun 8th, '11, 15:46

It's possible to create a new button 'save' to save the data in ADD mode, but that does not leave the insert page? A sort of 'Apply' button.

Thank you ;)

administrator
Site Admin
Site Admin
Posts: 5997
Joined: Jan 7th, '09, 23:18
Contact:

Re: Create new button

Postby administrator » Jun 9th, '11, 08:14

No, it's impossible.
But you may add redirection to add mode after successful insertion.
Read here how to do this:
viewtopic.php?f=33&t=97

dednrgrid
Junior
Junior
Posts: 16
Joined: Jun 1st, '11, 11:00

Re: Create new button

Postby dednrgrid » Jun 9th, '11, 10:57

Thanks for the quick response!
I would need to do a redirection to Add mode of another grid.
I have first datagrid 'News' and secon datagrid 'Image News'. When I do the insertion of the News I woud like to be redirect to Add mode of Image News.
Is it possible?

administrator
Site Admin
Site Admin
Posts: 5997
Joined: Jan 7th, '09, 23:18
Contact:

Re: Create new button

Postby administrator » Jun 13th, '11, 08:13

Yes, it's possible. Simply redirect it with ?new_datagrid.php?xxx_mode=add

dednrgrid
Junior
Junior
Posts: 16
Joined: Jun 1st, '11, 11:00

Re: Create new button

Postby dednrgrid » Jun 13th, '11, 08:59

Summarizing:
- I added these lines of code into datagrid code to receive mode and record ID:

Code: Select all

$mode = (isset($_REQUEST['n_mode'])) ? $_REQUEST['n_mode'] : "";
$rid = (isset($_REQUEST['n_rid'])) ? $_REQUEST['n_rid'] : "";
$pid = (isset($_REQUEST['n_pid'])) ? $_REQUEST['n_pid'] : "";


- I added these lines of code after $dgrid->Bind(true);:

Code: Select all

if(($mode == "add") && ($rid != "-1") && $dgrid->IsOperationCompleted()){
     echo "document.location.href=image_grid.php?img_mode=add";
}


But it does not redirect to the image_grid page. It only add a new record.

dednrgrid
Junior
Junior
Posts: 16
Joined: Jun 1st, '11, 11:00

Re: Create new button

Postby dednrgrid » Jun 13th, '11, 10:29

I solved by changing this:

Code: Select all

($mode == "add") && ($rid != "-1")


with this:

Code: Select all

($mode == "update") && ($rid == "-1")


Can I pass a default value to a field (dropdownlist) of the new datagrid (image_grid) after redirection?

thanks for your help!

administrator
Site Admin
Site Admin
Posts: 5997
Joined: Jan 7th, '09, 23:18
Contact:

Re: Create new button

Postby administrator » Jun 14th, '11, 12:30

Code: Select all

 echo "document.location.href=image_grid.php?img_mode=add";


This is not a JavaScript code, you have to write:
echo "<script> document.location.href=image_grid.php?img_mode=add; </script>";

dednrgrid
Junior
Junior
Posts: 16
Joined: Jun 1st, '11, 11:00

Re: Create new button

Postby dednrgrid » Jun 14th, '11, 12:46

Thanks!

I added javascript tags and it works: I insert the news in news_grid, after add operation there is the redirection to add mode of image_grid; the image_grid has a field called 'news' that is the title of the news. Is there a way to pass the value of the title added in news_grid to the related field (dropdownlist) into image_grid (as a default value)? I want the dropdownlist value already set on the title of the news that I just added in news_grid.

I hope I was clear.
Thank in advance for your help! ;)


Return to “Additional operations implementation”