0

In agiletoolkit, i have a set of views displayed and in the View, have set the outer div to have id=

  1 <div id='<?$_name?>' class='taskrow'>
  2   <div class=fleft nomargin>
  3     <?$Story?>
  4   </div>
  5   <div class='container'>
  6     <div id='<?$workspace?>' class='workspace'>
    ..
  34 </div>

In the page, i have a foreach loop that retrieves data from mysql and adds it to the page. At the same time, it stores the return of $p->add into an array using the id as the key.

     foreach ($st as $row) {
        if (is_array($row)) {
            $storyid=$row[0];
            $scrumrow[$storyid]=$p->add('View_StoryRow')
               ->setWorkspace('ws-'.$storyid);

When an action is performed (dragging an element on the screen), i refresh the page and a get block applies some updates to the database. I then have the following code to update the view (which is the row where the action was performed)

  if($_GET['task'] && $_GET['status'])
   {
          .. do database updates here ..
          $js[]=$scrumrow[$ajaxstory]->js()->reload();
  //      $js[]=$p->js()->reload(array('member'=>$member, 'sprint'=>$sprint));

          $this->js(null,$js)->execute();
   }

If I comment out the $scrumrow[$ajaxstory] row and use the commented line to refresh the whole page, it works but is very slow (some 12 seconds) as there is a lot on data the screen but when trying to refresh just the view, i get an error as in the headline, 'Unable to cut object with name ... It wasn't initialised.

enter image description here

The updates are done in the database so if i refresh the page manually, it works and the error does appear in place of the row i want to refresh and does give the correct name of the row (as seen in the ID using firebug) but what have I missed ? How do i initialise the objects which are already in the page ?

Trevor North
  • 2,286
  • 1
  • 16
  • 19
  • quick question your if ($_GET[]... ) -- is that placed after your foreach loop? I assume it is, but just to be sure make sure it is. – jancha Jun 25 '12 at 21:51
  • Yes - it's a separate block enclosed within the function init() { }. If i change the $js[] line in the above for the commented one, it works but it takes about 12 seconds hence why i want to refresh just the row and not all rows. Could it be something to do with the way atk4 is assigning the $_name that in the ajax returned code it doesnt give the same number so the id stored the first time the page is built isnt present when it builds it the second time ? – Trevor North Jun 26 '12 at 06:29
  • 1
    That's probably because you are loosing some of the get arguments. Try opening Inspector and trying to see which URL is using for reloading and how it is different to the original. The error message means that your view haven't been initialized. Try opening URL in new window and removing cut_object to see what's wrong. – romaninsh Jun 27 '12 at 21:44

1 Answers1

1

I added

$p->api->memorize('scrumrow',$scrumrow);

just before the if ($-GET[]..) block and then added

$scrumrow=$p->api->recall('scrumrow');

before I do any population of the $scrumrow in the page.

It does update the row so this answers the original question - that when the ajax is drawing part of the page, it is losing the array and doesnt rebuild it.

It does cause some side effects such as the drag and drop is not rexecuted for the new row and, strangely, i also got the following errors when clicking on any of the other pages via the menu links after the ajax row refresh.

Low level error: Class Model_Table is not defined in included file in include_once()

Think i'm going to stick with refreshing the whole page (as there is another functional issue with only refreshing the row) so i need to figure out why it's taking 12 seconds to execute the POST and GET.

Trevor North
  • 2,286
  • 1
  • 16
  • 19
  • 1
    "Low level error: Class Model_Table is not defined in included file in include_once()" this might happen if you have your own Model/Table.php somewhere and it does not have actual "Model_Table" class in it. btw, are you on 4.2? If no, I would suggest migrating to that asap. – jancha Jun 27 '12 at 13:28
  • I noted Romans is making a lot of changes. I've downloaded 4.2 but seen a few notes such as needing to change the database types for boolean and form layout stuff not working in 4.2. I'm trying to get my application to a release version and need to add functionality so at this point in time, dont want to have to go back and make changes to working code. Upgrade of atk4 will be an exercise later once i have a stable application on 4.1 – Trevor North Jun 29 '12 at 10:38