Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRID Footer #537

Closed
viceamiral opened this issue May 1, 2014 · 12 comments
Closed

GRID Footer #537

viceamiral opened this issue May 1, 2014 · 12 comments
Milestone

Comments

@viceamiral
Copy link

HI, I am using the Apydatagrid for my project
my problem is i can't get a summary rows for the showed columns.
for exemple i would like to get a sum data in the bottom of each columns
thanks

@Abhoryo
Copy link
Member

Abhoryo commented May 2, 2014

There is already a issue for this point:

#207

@viceamiral
Copy link
Author

Thanks dear Abhoryo, I will try to fix it

@viceamiral
Copy link
Author

Hi Abhoryo,
My problem is i would like to get the sum of the new column 'workedTime', this is my code :

        $source = new Entity('GtempsOutinBundle:Outin');
        $grid = $this->get('grid');
        $grid->setSource($source);
        // WORKED time NEW column
    $workedTimeColumn = new TimeColumn(array(
            'id' => 'workedTime',
            'title' => 'WORKED TIME',
            'filterable' => false,
        ));
        $source->manipulateRow(
            function ($row){
                $timeOut = $row->getEntity()->getTimeOut();
        $timeIn = $row->getEntity()->getTimeIn();
        $workedTime = $timeOut->diff($timeIn);
        $row->setField('workedTime', $workedTime->format('%H:%I:%S'));
                return $row;
         }
            }
        );  
      $grid->addColumn($workedTimeColumn);

// you can see that i added the new column with time value but i can't calculate the sun of the added column cells
I made a lot of search but i failed
COULD YOU GIVE ME HELP PLEASE ????

@Abhoryo
Copy link
Member

Abhoryo commented May 18, 2014

Can you draw me a data table with all the values displayed like you want (database values and calculate values) ?

@viceamiral
Copy link
Author

DATE || IN || OUT || WORKED TIME || REGULAR || OVER TIME || ABS TIME
2014-05-18 || 12:25:28 || 20:26:17 || 8:00:49 || 08:00:00 || 0:00:49 || NULL
2014-05-18 || 12:38:13 || 12:38:33 || 0:00:20 || 08:00:00 || NULL || 7:59:40

the worked time is the diffirence betwwen IN and OUT
regular time is fixed value
OVER TIME is the POSITIF difference between WORKED and REGULAR time
ABSENCE TIME is the POSITIF difference between REGULAR and WORKED time

NB: i calculated the workedTime and the OverTime ans AbsenceTime BUT I can't do the sum of thease columns
Thanks

@Abhoryo
Copy link
Member

Abhoryo commented May 18, 2014

This is just a PHP problem.
I think you should convert the over and abs time into seconds and perform a simple sum with integer values that you convert in time.

@viceamiral
Copy link
Author

thanks @Abhoryo ,
I have already the calculation of Worked and Overtime and Abstime
the problem is when i got the grid with the calculated columns i can't calculate the sum of the column's cells
I have used the manipulateRow to add values to cells of added columns (worked, over, abs)
BUT HOW can i get the array values of added column cells ???

@Abhoryo
Copy link
Member

Abhoryo commented May 18, 2014

For each line or for the whole grid?

@viceamiral
Copy link
Author

for the whole grid

@Abhoryo
Copy link
Member

Abhoryo commented May 18, 2014

Ok that's different.

The only solution I think is that you tweak the template for the sum of each row and then add a line to show the result.

@viceamiral
Copy link
Author

thanks @Abhoryo
Do you know a function that could get the values of added columns ???
for exemple $grid->getColumn('id_of_column')->getValues();
you know that these values are not inside the Database

@Abhoryo
Copy link
Member

Abhoryo commented May 19, 2014

No, plus you can't store all the values because you have pages.

@hmert hmert modified the milestone: 2.3 Dec 13, 2015
@hmert hmert closed this as completed Dec 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants