1 (edited by Kalido 12/22/2015 02:03:50 pm)

Topic: How to include checkbox in Table Pager

Hi,


Kindly, I couldn't add a column in the db_pager containing checkboxes. Is it possible ?
Perhaps I need to modify the sql's by adding a virtual column than include the checkbox field in the cols of the db_pager ? If so , how i can write it up :

_("chkbx") => array('insert'=>true, 'fun'=> 'echo"<input type=\"checkbox\" name=\"".$row['chknew']." value=\"".$nb."\">"'),

Regards,
Khaled Ali

2 (edited by apmuthu 12/22/2015 04:50:31 pm)

Re: How to include checkbox in Table Pager

Please state the context, function and the file you are trying to modify along with an intended screenshot of what you want to achieve.

There are:

includes/db_pager.inc
includes/ui/db_pager_view.inc

besides being called by various files both in the core and in the extensions.

Re: How to include checkbox in Table Pager

Hello,
Yes it is possible. Please have a look into Search not invoiced deliveries in Sales tab.
Here you will se a column with checkboxes for batching the deliveries.
Maybe you can get an idea from here.

Joe

Re: How to include checkbox in Table Pager

Thanks,

I m trying to have a new look for ..\gl\inquiry\journal_inquiry.php with which  I want to add a new checkbox column at the beginning
of the displayed table.

When selecting checkbox's , it will popup a set of control buttons who will allow us to Export the selected rows.

It is a some kind of additional control to add for List inquiry web pages used in different locations of FA.

Kalido

Post's attachments

checkbox-ex.JPG 17.1 kb, 1 downloads since 2015-12-22 

You don't have the permssions to download the attachments of this post.

Re: How to include checkbox in Table Pager

hey,

really i m thankful a lot.

Kalido

Re: How to include checkbox in Table Pager

Wouldn't you want to submit your code?

7 (edited by Kalido 01/11/2016 04:24:58 pm)

Re: How to include checkbox in Table Pager

I will submit the code, but until now I failed to hold the checkbox's when activating AJAX.

I added the checkbox's to a new Journal Inquiry page and trying to control the selection for exporting or printing out.

Any proposal ?

Post's attachments

NewJournal_Inquiry_Layout.JPG 77.7 kb, 1 downloads since 2016-01-11 

You don't have the permssions to download the attachments of this post.

Re: How to include checkbox in Table Pager

Attached your screenshot here for self-sufficiency.

Post's attachments

NewJournal_Inquiry_Layout.jpg 77.7 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: How to include checkbox in Table Pager

Hi,

I couldn't understand your comment, but I attached the pic to help figure out what i am working on.

Anyhow I appreciate any help in this regard.

I did a deep search for a solution on the net, but it seems it is a bit complicated to have such kind of control and I found nothing interesting unless advises to use $_session ( cookies ) when paginating to hold control of checked checkboxes.

I didn't found any sample to base my trials on it and because of that I tried to ask for suggestions.

For sure there is no selfishness when I said that I failed to do this exercise.    smile

Thanks,
Kalido

10 (edited by Kalido 02/09/2016 06:21:41 pm)

Re: How to include checkbox in Table Pager

Hi Joe,

Controlling the checkboxes in the tables rows are ok now ( learned how to do it from : bank_account_reconcile.php ),

but still I failed to control the top checkbox in their column header.

The idea is to use it as : check all / uncheck all / checked (whenever one of the rows checkboxes is checked)

AND whenever the header is being checked a tiny icon menu will  show up ( and this tiny menu will disappear when unchecked ).

Any suggestion ?

Regards,
Kalido

11 (edited by apmuthu 02/10/2016 05:42:35 am)

Re: How to include checkbox in Table Pager

The current implementation of the"X" in the checkbox column header is not designed to work as expected by you - in fact it does not have js attached to it.

Reference implementations are available at:
http://stackoverflow.com/questions/1928 … in-a-table
and
http://stackoverflow.com/questions/3862 … ox-in-html

Re: How to include checkbox in Table Pager

Thanks for your reply.

Khaled

13 (edited by apmuthu 02/16/2016 03:23:23 am)

Re: How to include checkbox in Table Pager

When done, please submit patches here for peer review and possible inclusion in FA 2.4.

Re: How to include checkbox in Table Pager

Hi,

to resolve the checkboxes select/deselect in the rows, I did the following :

- I added a temporary field column "sel_chk" to the $sql used in journal_inquiry ( based on adding join the existing "gl_trans" to temporary table containing [ clone of gl_trans.counter & sel_chk]

- I controlled their previous selection  within the $sql pagination by adding a $_session var for the journal_inquiry page & by adding a conditional check in db_pager_view.inc

- I imitate the selection checkboxes as in : /gl/bank_account_reconcile.php and it works ok for the rows.


Now for doing the check ALL case in the deader i m freezed:

- I cannot adopt the JAVASCRIPT approach as in the links because it deals with the seen page only, and when paginating it flashes away all the checkboxes ( I tried as described )

- I tried to call a php function through AJAX ( it looks a good approach ) but i failed because it seems that in this JAVA / AJAX / PHP connection, JAVSCRIPT establish a new connection tunnel for the communication and in this case it couldn't recognize all of the server original environment and and the relations were lost.

it is really a difficult exercise.

khaled

Re: How to include checkbox in Table Pager

Avoid sessions and keep the js local at the client side. Just toggle the state of the "select all" checkbox and on it's change based on it's current value, either populate or clear all target checkboxes and make sure the value of the "select all" checkbox is a blank string when submitting the form and it is to be ignored in the form processor.

16 (edited by Kalido 02/15/2016 06:53:05 am)

Re: How to include checkbox in Table Pager

currently, it works fine when clicking and staying in any table page

but when changing the page still there is a problem to be resolved.

//-------------------------------------------------------------------------------------------------------------------------
//               the bellow sequence is very important for controlling the checkboxes relation header / rows
//-------------------------------------------------------------------------------------------------------------------------
          
$id = find_submit('_rec_');      // check if a row was clicked

if (!check_value('chkbx')) { update_all('0') ;  }   // always clear all the rows checkboxes whenever the header is not marked

if ( check_value('chkbx')==1 && $id == -1) { update_all('1') ;  }  // when we are sure that the header is
                                                                                                                      //  clicked and not one of the rows was clicked
       
if ($id != -1)                                  // when a row is clicked => toggle its mark & update the "sel_chk" field to (0 || 1 )
        {
            $chkbox_value = check_value("rec_".$id) ? '1' : '0';
            update_gl_trans_sel_chk_value($id,$chkbox_value);
        }

//--------------------------------------------------------------------------------------------------------------------------
//               the above sequence is very important for controlling the checkboxes relation header / rows
//--------------------------------------------------------------------------------------------------------------------------


I m sure now that things are on the right track.

- the goods is I didn't use javascripts until now except of the standard ((( JsHttpRequest.request("_XXXX_update", this.form); )))

- the bads is that I was obliged to control the header checkbox through modifications in db_pager_view.inc file:

related to   :    $labels[0]   <==>  $table->columns->headers[0]   ( table header )


thanks for your support

Khaled

Re: How to include checkbox in Table Pager

As the db_pager_view.inc is a core file, modifying it may not be good. Checking the file that @joe suggested may be useful.