Dev gridview nesting

Source: Internet
Author: User

Dev has done a lot recently and wants to make the program look professional. So I have studied it a little.

This article only records how to click a row in the list to open the content of the associated sub-table in this row. The effect is as follows:


The implementation process is as follows:

1. In the designer:


Create an entryview (create a new level) under mainview so that the gridcontrol contains two gridview entries.

Then open your designer (run designer)

If you are only testing, or If Party A has no requirements for the beauty and ugliness, you do not need to set the settings.


2. Bind data

Like normal binding, gridcontrol. datasource = dataset. Table [0];

The difference is that there must be two tables in this dataset, and Table1 and Table2 must be the relationship between the master and slave tables (the main table has a field that is a foreign key from the table to form a relationship ), for example, it's not like it. It's a bit lazy.

Stored Procedure:

Select outstockplan. * From t_outstock_plan as outstockplan where outstockplan. billdate <@ maxdate_invo and outstockplan. billdate> @ mindate_invo

Select ospe. * From t_outstock_plan as OSP
Left join t_outstock_plan_entry ospe on OSP. onlyid = ospe. voucherid
Where OSP. billdate <@ maxdate_invo AND osp. billdate> @ mindate_invo

A stored procedure returns two tables at the same time. The first statement returns the row of the primary table, and the second statement returns the row of the child table corresponding to the information of the primary table. As long as it is not too troublesome, You can execute it separately. I am still a little lazy.

Access execution:

Wmsds relationds = This. _ wmsaccess. select_outplanandentry_relation (dates, datee); // executes the preceding stored procedure and returns a dataset containing Table1 and Table2


Datarelation DR = new datarelation ("Notification entry", new datacolumn [] {relationds. t_outstock_plan.columns ["onlyid"]}, new datacolumn [] {relationds. t_outstock_plan_entry.columns ["voucherid"]}); // a new table relationship bound with the keys of two tables

Relationds. relations. Add (DR); // Add a table that is related to Dataset

Front-end binding:
Grid_voucherplanlist.datasource = relationds. Tables ["t_outstock_plan"]; // bind the master table to gridcontrol as a datasource.


Close.




Dev gridview nesting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.