Hi Steve,
How would you add a customized action which took into account the items checked in the list view ?
My problem is how to get the checkbox values into my action.
Thank you
Jean
How to use checked elements in the list for an action ?
11 posts
• Page 1 of 1
How to use checked elements in the list for an action ?Hi Steve,
How would you add a customized action which took into account the items checked in the list view ? My problem is how to get the checkbox values into my action. Thank you Jean
Hi Jean,
This is a 3 part process: 1. Add an entry in the actions.ini file. 2. Create a javascript function for pass parameters to the PHP action. 3. Create a custom action (PHP) to do the work. As an example we will consider the update selected action. The actions.ini file entry looks like:
Key things to notice here: 1. The url refers to a javascript function, which takes a single parameter referring to the result list. 2. The category is 'selected_result_actions'. This is what causes the button to appear along the bottom of the result list. Now the javascript function looks like:
Things to notice here: 1. It takes a single parameter: tableid which refers to an html table (which is passed in the call to our function in the url attribute in the actions.ini file. 2. We obtain the selected record ids by calling the getSelectedIds() function (part of the xataface distribution). 3. We obtain a reference to the select list form and append an element for the selected ids (to pass to the PHP action). We also set the '-action' element of the form to name our PHP action that we will create. 4. Then we submit the form. Finally, let's look at the PHP action. It basically needs to obtain Dataface_Record objects corresponding to the selected ids, and do something....
Notice the use of the df_get_selected_records() function to obtain an array of records. From here you can do what you like with the action. Hope this makes sense. Let me know if you require clarification. -Steve
Hi Steve,
I have dealt with this situation completing your javascript to create a new field dynamically. All this to grab a variable and know if the added button have been clicked on. Here I create a hidden input field called bouton with the value of 1. Then in the copy_replace.php action file, I add a if block and can do what I want with it. Here is the javascript code
Hope this will help. Jean
Problems with selected recordsSorry for open an old thread..
I'm using xataface ver:1.1.5 Hi I have white this action.ini
and this file (named:stampa.php)
But array $records is always empty!! Where is mistake??? Sorry for my bad English!!
Sorry for my poor ItalianEnglish.......
I find error...I have to remove url command on action.ini with:
All it works!!
Just a note, in INI files you comment out with a semi colon, not a # sign.
e.g.
should be
Your solution worked only because it changed the 'url' parameter to be named '#url' instead.
Re:
I reanimate this post because I want to do the same thing as described here but beeing a noob in javascript, I don't find in documentation where you save your javascript : in a specific java file (but then how the xataface knows how to find it?), in the php code of the page (I tried but it didn't work), in the source file with the other functions such as updateSelected (it will disturb me a little)? I'm sorry if it's a quite basic question but I really can't find the answer by myself
Re: How to use checked elements in the list for an action ?Javascript can be included anywhere on the page. Generally you would implement a block or a slot to add the necessary script tags.
e.g. in the application delegate class you might use the curstom_javascripts block:
Re: How to use checked elements in the list for an action ?Thanx.
I must be a little clumsy but it doesn't work. code of the javascript calculate.js located in my the repertory of my table named "Annee_2010"
Code of my actions.ini
The code of Annee_2010.php
And I have a file named calculate.php in the actions repertory of my site. It works if I use the following actions.ini
Is there a big mistake i haven't seen or something I don't understand in the way xatafce works?
11 posts
• Page 1 of 1
Who is onlineUsers browsing this forum: No registered users and 9 guests |