|
Twitter Feed
|
Found 1 of 135 records in table Wiki
Now Showing 1 of 1 Current Record: Selected_Records_ActionsSelected_Records_Actions[Permalink]Creating a Custom Selected Records ActionIf you view the list tab in any of your Xataface applications, you'll notice that there is a checkbox next to each row of the list, and there are a number of actions listed at the bottom of the list that you can perform on the selected records. Xataface comes pre-built with only a few of these actions:
However it is quite easy to add your own actions here that are performed on selected records. This article describes exactly how to do this. What is a Selected Record action?A Selected Record action is no different than any other action in Xataface, except that it is meant to act on the records that have been selected in the list tab. Example Action: Approve RecordsConsider a news site where news stories are automatically imported into the database en masse, but each news story has a field approved to indicate whether the store has been approved to appear on the site yet. The usage pattern of this application involves a lot of looking through lists of news stories and approving them. Therefore it would be convenient if the user could just select the rows that he wants to approve and click a button to approve them all. Out of the box Xataface would allow the user to select the records, click update selected records, then update them all via the update selected records form. But avoiding this extra step will improve usability greatly. Step 1: Design the ActionFirst we need to specifically decide how our action will work. In this case, the flow goes as follows:
Step 2: Gather Our ToolsBefore we actually create the action, let's look at a few tools that we'll be using from the Xataface framework to make this happen.
Step 3: Create the ActionWe will call our action approve_news so we'll place it in the actions/approve_news.php file of our application:
Step 4: Add the action to your actions.ini fileThe actions.ini file allows us to specify how and where this action is used, and by whom. We can specify permissions that are required to perform the action, conditions that are required to display the action, confirmation messages that are to be displayed to the user when they are about to perform the action, and more. Our actions.ini file entry looks like:
This should be fairly straight forward. The only special items here are the category and confirm directives. The condition directive tells Xataface that this action should only be shown for the news table. The confirm directive defines a confirmation message that should be displayed to the user when they attempt to approve records. The icon directive allows you to specify the path to an icon to display for the action. In our case we have an icon located in the images directory of our application. Step 5: Trying it outNow when we go to the list tab of the news table there is an Approve button along the bottom where it says "With Selected". You we can click on this button to approve any of the selected rows. blog comments powered by Disqus |