I have a search form that the user uses to find persons from the database, the results are displayed on a table, then the user can choose persons from the results table and add them or remove them from another table (the CGridView) and this last table will be saved to the database when the user clicks save button. My problem is that I'm adding and removing the persons (the rows) with jQuery, so when I use the sort function of the CGridView, clicking any header, the rows that were added with jQuery are lost. Also, when I remove rows from the last table I want to refresh the table so the zebra style rearranges. How can I do this without losing the data added with jQuery?
Related
I have a table which can add up rows (insert row() method in js) when clicked on a button.
First column has a select tag which is populated with the product names from data base. Second column has a input text box for quantity. Next is a button. When I click on the button it should multiply the price of the selected item from first column with the quantity and set the answer to the next column i.e price.
This is working for only one row. When I add new row and click the button for setting price, it will take the value of first row itself.
This all should be done on application level on client side with proper server side checks on submission. You shouldn't need database CRUD at this point.
I am creating a table that displays a list of customers and their information. I have a few filters that, when selected, modify the table as needed and do so automatically. But when I click the Filter button underneath to save the filters selected and add them to the URL, the URL changes to the correct address but the table returns to the original table. Any ideas how to have the filters not reset when clicking the filter button?
I want to edit/update, multiple rows together in Yii CGridView.
Say, each row has a checkbox and a single edit/update button, I select multiple rows and by clicking on edit/update button all selected rows are opened for editing and update.
Is this possible with Yii CGridView..??
Use the selectableRows property of the CGridView.
According to Yii Documentation for CGridView
public integer $selectableRows;
the number of table body rows that can be selected. If 0, it means rows cannot be selected. If 1, only one row can be selected. If 2 or any other number, it means multiple rows can be selected. A selected row will have a CSS class named 'selected'.
You can use the the $.fn.yiiGridView.getSelection(containerID) to retrieve the key values of the selected rows.
Add some more buttons either at the top or bottom of the gridview with actions for edit, delete or whatever action you need to take and pass the key values retrieved above.
If you want to edit rows in-line you can use extension phaActiveColumn which I messed up to support multiple rows (the whole table if desired).
EDIT: well, the extension basically creates an input field replacing the grid cell when user clicks on the cell. The field will have the cell's value for starters and it then sends an ajax call to controller, as soon as the user presses enter, asking to save the value of the field, which will be the user's input.
My addition was to create one such field for every cell in the row and store user input in javascript objects which then get send all at once with one ajax call to the controller. Multiple row updates are supported (creating adequate number of javascript objetcs).
If anyone has any interest in this there it is.
phaEditColumn2
phaAbsActiveColumn2
I am using Dreamweaver to create a site.
I have created my database within phpMyAdmin and have two tables set up that contain the data I wish to display on my site. (it is a football team site and the page I am editing displays player profiles).
I have set up a drop down box, which is connected to my players table in phpMyAdmin. This I have set to display surname of the player. (I've set up the recordset to retrieve all data from my "players" table)
Below that, I have another div which contains text that I want to display based on the selection on the drop down list. For example, Position, appearances, goals, assists, etc.
Position: Dynamic text to be displayed here
Appearances: Dynamic text to be displayed here
etc
(This data would come from the "players_info" table - but the two tables are connected via the player_id field which is contained in both)
What I can't seem to do is work out how to get the text to update when the user would select a player from the drop down list.
Any help would be greatly appreciated.
Thanks
James
You can do these using ajax function.
when you select a player name ,then javascript or jquery event will be called which include a php file.
This php file must contain the sql which fetch your desired player information.
when server give response, then display it your corresponding div
I currently have a PHP form that uses AJAX to connect to MySQL and display records matching a user's selection (AJAX: Display MySQL data with value from multiple select boxes)
As well as displaying the data, I also place an 'Edit' button next to each result which displays a form where the data can be edited. My problem is editing unique records since currently I only use the selected values for 'name' and 'age' to find the record. If two (or more) records share the same name and age, I am only able to edit the first result.
Let's assume your file for editing is edit.php. Then, in the file where you generate the edit links, try changing your edit button link as follows:
'edit'
Then you will be able to access ID variable as
echo $_REQUEST['ID'];
Note that the ID is case sensitive. Let me know how it goes.
when displaying records from ajax, also send the primary field(id in most cases) along with name and age
and when u are displaying these data along with edit incorporate that primary field with edit