A plurality of drop-down box binding data

Binding data drop-down box, it is first to complete a single processing table data for these tables. The methods of data School, grade, class three tables of this single-table queries check out. Examples will be described with class. Here Insert Picture Description
The first is data-bound college drop-down box, which is a single-table query data, to write about a single query method in the controller table data. Here Insert Picture Description
SelectVo entity is a new class added to display the value (text) and select value (id) to put the entire project in the drop-down box. Then from inside the database query, the database table of college return value into SelectVo objects inside it. And then stitching "- select -" item. Finally, return to the page.
Then look at the page code:
Here Insert Picture Description
this college drop-down box binding data on it!
The next step is to bind data-grade drop-down box, look at the code:
Here Insert Picture Description
First, write a change event, when the college drop-down box to change the data will get re-selected college ID, the ID and then will get to get to the ID to tie check out the grades have been given the drop-down box data.
Code-year drop-down box query data:
Here Insert Picture Description
single-table queries of single-table queries and college grades drop-down box data drop-down box data about the same, just one more than the college query condition grade drop-down box data (year college ID to the table Like pages pass over college ID). Then stitching "- select -" item; and finally returned to the page. Year after completing a query to return information page drop-down box method to bind data request again, and finally to empty the class drop-down box (mainly due to changes in college information to be able to determine if in fact this class after the data still need to select a senior information ).
The last year is to change the drop-down box to trigger data binding class drop-down box data, look at the code:
Here Insert Picture Description
Information in this class is mainly determined by the School of Information and grades; grades to write a change event information, class information will be because senior information changes rebind a certain class of data under this year.
After the year when the information changes will be selected to reacquire year college ID and ID, the ID will be passed to obtain inside the controller class information query method on it. And then bind the data based on the drop-down box already check out the class information.
Code controller:
Here Insert Picture Description
according to the page pass over college ID, ID-grade classes to database tables inside the query, the query there are two, one is the class of college ID table is equal to the page you want to pass over college ID, there is a exterior grade class is to wait for the page ID pass over the grades ID. SelectVo returned data into objects, and finally "- select -" splicing item. Class information query has been good. Back to the output.
Here, the binding of the three drop-down box data on the well. See the effect:
Here Insert Picture Description
The first is the binding of college drop-down box data after the page is loaded directly bind, and then select the drop-down box year after the data of a data strip on the binding of college, and then selecting one of the data-grade drop-down box, followed by binding data class drop-down box.
Then after college information data and then change the drop-down box, it will rebind the data-grade drop-down box and clear the data class drop-down box.
Here Insert Picture Description
This whole a drop-down box bound data results came out, and if there is what's wrong, please comment in the comments area!

Guess you like

Origin blog.csdn.net/weixin_44560796/article/details/90272940