Using Mate as an Edit Form

Discuss MySQL Ajax Table Editor

Using Mate as an Edit Form

Postby mcl » Tue Nov 02, 2010 9:40 pm

I have my own search of the records in a table, which displays matching records. I would like to have an EDIT Button on each record of my display, which would take me directly to the EDIT form in MATE and on exiting, Update or Cancel, return me to my search page.

or if the above is too complicated, how can I force MATE to just show the matching record for a unique field. I would then only have the Edit Button, show for the single row displayed. Like when you return to Mate and it has remembered your last search

Any pointers would be appreciated, as my searching failed to find a similar question.

Thanks

Richard
mcl
 
Posts: 33
Joined: Tue Mar 03, 2009 10:52 am

Re: Using Mate as an Edit Form

Postby admin » Wed Nov 03, 2010 3:22 pm

You can pass a get variable with the row id and then go straight to the edit screen. To do this, in the displayHtml function at the bottom change the javascript to
Code: Select all
         <script type="text/javascript">
         
            trackHistory = false;
            var ajaxUrl = '<?php echo $_SERVER['PHP_SELF']; ?>';
            <?php
            if(isset($_GET['edit']))
            {
               echo 'toAjaxTableEditor("edit_row","'.$_GET['edit'].'");';
            }
            else
            {
               echo 'toAjaxTableEditor("update_html","");';
            }
            ?>
         </script>

And then to forward the user add this php function and call it using the afterEditFun callback
Code: Select all
   function forwardUser($id,$info)
   {
      $this->Editor->retArr[] = array('where' => 'javascript', 'value' => 'window.location="test.php?id='.$id.'";');
      echo json_encode($this->Editor->retArr);
      exit();
   }

      $this->Editor->setConfig('afterEditFun',array(&$this,'forwardUser'));

admin
Site Admin
 
Posts: 1502
Joined: Fri Jul 11, 2008 1:34 am

Re: Using Mate as an Edit Form

Postby KarelB » Fri Nov 05, 2010 3:15 pm

I have a similar problem and from one page I try to jump into the add mode of a table ( and afterwards return to the launch page)

Itried to use the following construct in the :
Code: Select all
$javascript = '   
         <script type="text/javascript">
            setAjaxInfo({url: "'.$_SERVER["PHP_SELF"].'", history: true});
            if(ajaxInfo.history == false)
            {
               toAjaxTableEditor("add_row","");
            }
            else if(window.location.hash.length == 0)
            {
               var defaultInfo = {info: "", action: "update_html", sessionData: "'.$defaultSessionData.'"};
               window.location.href = window.location.href+"#"+Base64.encode(Object.toJSON(defaultInfo));
            }
         </script>';
      echo $javascript;


But this will just show me the table screen and not the add screen.
What am I missing?
cheers
KArel
KarelB
 
Posts: 458
Joined: Mon Dec 01, 2008 11:49 pm
Location: The Netherlands

Re: Using Mate as an Edit Form

Postby admin » Fri Nov 05, 2010 3:30 pm

In the paid version you need to do it differently. Try changing update_html to add_row in the else if clause.
Code: Select all
$javascript = '   
         <script type="text/javascript">
            setAjaxInfo({url: "'.$_SERVER["PHP_SELF"].'", history: true});
            if(ajaxInfo.history == false)
            {
               toAjaxTableEditor("add_row","");
            }
            else if(window.location.hash.length == 0)
            {
               var defaultInfo = {info: "", action: "add_row", sessionData: "'.$defaultSessionData.'"};
               window.location.href = window.location.href+"#"+Base64.encode(Object.toJSON(defaultInfo));
            }
         </script>';
      echo $javascript;
admin
Site Admin
 
Posts: 1502
Joined: Fri Jul 11, 2008 1:34 am

Re: Using Mate as an Edit Form

Postby KarelB » Fri Nov 05, 2010 3:46 pm

Admin

Excellent! Works like a charm.
Just for my understanding: Is the else clause for when you enter the script the first time, hence there is no Sessiondata for this script?

Thanks again,

Karel
KarelB
 
Posts: 458
Joined: Mon Dec 01, 2008 11:49 pm
Location: The Netherlands

Re: Using Mate as an Edit Form

Postby admin » Fri Nov 05, 2010 3:58 pm

Yes that is correct.
admin
Site Admin
 
Posts: 1502
Joined: Fri Jul 11, 2008 1:34 am

Re: Using Mate as an Edit Form

Postby calebdavenport » Wed Dec 07, 2011 5:43 pm

Along these same lines, I am looking to create a link to view a specific row from different tables.
Using the first method the admin posted here worked great in the free version. I have since upgraded to the paid version. I can get it to work somewhat, but not sure what I need to do for the history functionality to maintain that working.
So, what I need to do is check for a URL variable, and if one exists for 'id' go to the record that matches that ID and maintain the history.
Thanks
calebdavenport
 
Posts: 1
Joined: Wed Dec 07, 2011 5:32 pm

Re: Using Mate as an Edit Form

Postby mukeshdak » Sun Jan 20, 2013 8:22 pm

Following code worked for me in paid version for editing a specific record

Code: Select all
   
    $javascript = ' 
      <script type="text/javascript">
        setAjaxInfo({url: "'.$_SERVER["PHP_SELF"].'", history: false});
        if(ajaxInfo.history == false)
        {
        toAjaxTableEditor("edit_row","'.$_GET['edit'].'")
        }
        else if(window.location.hash.length == 0)
        {
          var defaultInfo = {info: "", action: "update_html", sessionData: "'.$defaultSessionData.'"};
          window.location.href = window.location.href+"#"+Base64.encode(Object.toJSON(defaultInfo));
        }
      </script>';
    echo $javascript;
mukeshdak
 
Posts: 30
Joined: Fri May 11, 2012 3:18 pm

Re: Using Mate as an Edit Form

Postby pedroriv » Thu Feb 05, 2015 8:16 am

and as we do the same to operate in the pro version ?
thanks
pedroriv
 
Posts: 3
Joined: Sun May 15, 2011 5:35 am


Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron