RecordGrid not sortable for a custom action

A place for users and developers of the Xataface to discuss and receive support.

RecordGrid not sortable for a custom action

Postby Jean » Wed Jul 02, 2008 7:08 am

Hi Steve,
I send a good array for my grid. Here is the result I send to the grid through the object $this->records :

Code: Select all
Array
(
    [id] => tte83545
    [annee] => 2007
    [nom] => Le bois du roy
    [commune] => idron
    [maitre_ouvrage] => Sivom
    [nombre_logements] => 318
    [type_logements] => NEUF
)


Then I have this warning
Code: Select all
Warning: array_keys(): The first argument should be an array in /var/www/html/xataface-1.0-beta-3/Dataface/RecordGrid.php on line 100

The line from where all this is caused by is
Code: Select all
$columns = array_keys($sampleRecord);

The warning is OK but I don't understand the 2 lines preceding this error:

Code: Select all
      $recKeys = array_keys($this->records);
      $sampleRecord =& $this->records[$recKeys[0]];

These two lines force $sampleRecord to be a record and not a string.
I don't see how to feed it with something else.
I hope I am clear enough.
Jean
Last edited by Jean on Thu Jul 10, 2008 12:28 am, edited 1 time in total.
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Postby shannah » Wed Jul 02, 2008 9:56 am

Hi Jean,

I The record grid requires you to pass it an array of either arrays, records, or related records. It looks like you have passed it only an array.

The lines you are referring to effectively peek at the first item in the array so that we can figure out the columns we need (the next section figures out the columns), whether the first item is an array or a record.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Jean » Thu Jul 03, 2008 2:06 am

Thank you Steve. Well I understand the logics.
I succeeded to display the recordGrid but without any link in the column headings to sort by any column.

    Did I miss something in the installation ? I just kept my app unchanged, just changed the url to the Xataface beta 3 although it had been built with the 0.7.1 version.
    Is the fact that my data comes from several tables has any influence ?
    Did I miss any line to include so that some javascript would be included in my column headings.

I search explanations in the forum but the recordgrid questions were often before the version 1 and I did not find any solution.
id is set on "sortable".
Kind regards
Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Postby Jean » Fri Jul 04, 2008 1:35 am

I use MySQL 4.1.18 so I cannot use any view. With the temporary tables, I cannot use Ajax. I look forward to use a xml file. Has anybody used this kind of solution ?
Thank you
Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Postby shannah » Fri Jul 04, 2008 10:00 am

Hi Jean,

The record grid won't give a link per-se for sorting. However if you click in the heading of a column it should sort on that column using javascript (as long as the id of the record grid (the id attribute of the <table> tag) is "sortable".

I believe it will also work if the class is sortable.

If this is not the case, let me know, and I'll take a closer look. Do you have a URL that I can check it out?

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Jean » Mon Jul 07, 2008 5:42 am

Thank you Steve, very kind of you. Unfortunately, I am working on an intranet.
I tried to have a class sortable without any change. But I noticed one or two things.
Please look at the normal grid from a table
Image

The source page is &gt;table id="sortable" class="listing "&lt; ...
Code: Select all


            <thead>
            <tr><th><input></th>   <th><Expand></th>
            <th><a>Code de l'opération</a></th>


and all the javascript for each column.

Now with my custom action statistiques
Image
The source page is &gt;table id="result_list" class="listing"&lt;...
Code: Select all
   <thead>

      <tr>
            <th>Id</th>
            <th>Annee</th>
            <th>Nom</th>
            <th>Commune</th>
            <th>Maitre Ouvrage</th>

            <th>Nombre Logements</th>
            <th>Type Logements</th>
            </tr>
   </thead>
   <tbody>
            <tr>
                  <td>000001</td>

                  <td>2008</td>
                  <td>Résidence</td>
                  <td>Pau</td>
                  <td>Habitat</td>
                  <td>65</td>
                  <td>NEUF</td>

               </tr>
         </tbody>
</table>


I sent this data to the template in my action file
Code: Select all
$info = array();
  while ( $rang = mysql_fetch_assoc($resultat) ) {

$info[]=$rang;
}

import('Dataface/SkinTool.php');
import('Dataface/RecordGrid.php');
$grid = new Dataface_RecordGrid(& $info);

df_display(array('body'=>$grid->toHtml()), 'Dataface_Main_Template.html');
exit;


As you can see I don't have te same display nor the same id... for the table in both cases.
Thank you Steve for your help
Jean :)
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Postby shannah » Mon Jul 07, 2008 10:05 am

Hi Jean,

Yes.. It doesn't appear to be picking up the id sortable. It occurs to me that you also need to update your Dataface_RecordGrid.html template. If you copy the one from 1.0-beta-3 it should work.

You'll know it is working when the table tag looks something like:

Code: Select all
<table id="sortable" ...>


-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Jean » Tue Jul 08, 2008 1:52 am

:oops: Oups Steve.

I switched the two source codes. Where I have the table id="sortable", it is the second image and it does not work.

And my Dataface_RecordGrid.html is the right one, the one from the 1.0-beta-3.

I don't know which track to follow. May be the template is a good hunch...

thank you
Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Postby shannah » Tue Jul 08, 2008 7:51 am

Hi Jean,

The images don't make it clear as the record grid doesn't use a conventional link. However if you click on the column headers id should sort (and will show a little arrow indicating the direction of the sort).
Can you provide a URL for me to take a look?
-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Jean » Tue Jul 08, 2008 11:19 pm

Sorry Steve, I am positive about the fact I don't have any link in the colum headings. And unfortunately there is no web access on the intranet where the application is.
Thank you
Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Postby shannah » Wed Jul 09, 2008 11:01 am

Sorry.. my mistake. You need to set the css class 'listing2' to get sorting ability.

Here is a sample action that creates a grid from an array, and is sortable:
Code: Select all
<php>'Steve', 'Age'=>24, 'Subject'=>'Math'),
         array('Name'=>'Paul', 'Age'=>28, 'Subject'=>'Socials'),
         array('Name'=>'Mary', 'Age'=>14, 'Subject'=>'Physics'),
         array('Name'=>'John', 'Age'=>10, 'Subject'=>'Spelling')
      );
      
      $grid = new Dataface_RecordGrid($data);
      $grid->cssclass = 'listing2';
      df_display(array('body'=>$grid->toHtml()), 'Dataface_Main_Template.html');
   }
}
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Jean » Wed Jul 09, 2008 11:29 pm

Thank you Steve it works! As great as your soft is, your availability and dedication are a great asset !
This line opens new perspectives for me
Code: Select all
$grid->cssclass = 'listing2';

Thank you
Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Postby Jean » Thu Jul 10, 2008 12:57 am

one last question Steve on this topic :
    *How can I load actions_menu_head block and actions_menu_tail to my page ?

Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Postby shannah » Sun Jul 13, 2008 9:29 pm

*How can I load actions_menu_head block and actions_menu_tail to my page ?

Sorry. Missed this question on the first time around. I'm not sure I understand the question exactly. Can you elaborate on exactly what you want to show?

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Jean » Tue Jul 15, 2008 5:23 am

Thank you Steve,
I need to have the csv link like this :
Image
in the result page of my action
Code: Select all
$info = array();
  while ( $rang = mysql_fetch_assoc($resultat) ) {

$info[]=$rang;
}

import('Dataface/SkinTool.php');
import('Dataface/RecordGrid.php');
$grid = new Dataface_RecordGrid(& $info);

df_display(array('body'=>$grid->toHtml()), 'Dataface_Main_Template.html');
exit;

Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Next

Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 32 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved