Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
English

How can we create a final row that displays aggregated values of the rest of the rows? This is especially important when it comes to reporting. One can design the form such that it serves as a report rather than a means of data entry.

The final row is not a mere record row but serves as a summary of the record rows.

Thai

เราจะสร้างแถวสุดท้ายที่แสดงมูลค่ารวมของแถวที่เหลือได้อย่างไร สิ่งนี้สำคัญเป็นอย่างยิ่งเมื่อพูดถึงการรายงาน หนึ่งสามารถออกแบบแบบฟอร์มที่ทำหน้าที่เป็นรายงานแทนที่จะเป็นค่าเฉลี่ยของการป้อนข้อมูล

แถวสุดท้ายไม่ใช่แถวระเบียนเพียง แต่ทำหน้าที่เป็นบทสรุปของแถวระเบียน

...

For this to happen, there are many ways to do it but we will focus on the dataset data loaded from its binderdata store. First, we can inspect how data is constructed.

Thai

สำหรับสิ่งนี้เกิดขึ้นมีหลายวิธีที่จะทำ แต่เราจะมุ่งเน้นไปที่ชุดข้อมูลที่โหลดจากสารยึดเกาะของมัน อันดับแรกเราสามารถตรวจสอบวิธีการสร้างข้อมูล

Image RemovedImage Added

The element in question here is a basic grid, let's click into it.

Thai

องค์ประกอบที่เป็นปัญหาในที่นี้คือกริดพื้นฐานลองคลิกเข้าไปดู

Image RemovedImage Added

The grid is using a pair of identical load and store data store binder (which makes sense most of the time so that data is stored and loaded from the same source). We can opt to use JDBC Binder data store as the load binder data store so that we can gain full control on how dataset is returned and constructed.

...

Thai

กริดใช้คู่โหลดที่เหมือนกันและที่เก็บสารยึดเกาะ (ซึ่งใช้เวลาส่วนใหญ่ในการเก็บและโหลดข้อมูลจากแหล่งเดียวกัน) เราสามารถเลือกใช้ JDBC Binder data store เป็น load binder data store เพื่อให้เราสามารถควบคุมได้อย่างเต็มที่ว่าชุดข้อมูลจะถูกส่งคืนและสร้างอย่างไร

ด้วยความสามารถในการกำหนดแบบสอบถาม SQL ของเราเองเราสามารถสร้างแบบสอบถามที่จะกลับแถวสุดท้ายเป็นแถวค่ารวม

Code Block
languagesql
select c_name, c_quantity, c_price, c_parentrequest_id from app_fd_purchase_items where  c_parentrequest_id = ?
union
select "SUM", sum(c_quantity), sum(c_price),  c_parentrequest_id from app_fd_purchase_items where  c_parentrequest_id = ?

And this is a sample result by running them on a command line interface.

...

Code Block
languagesql
+--------+------------+---------+---------------------------------+

| c_name | c_quantity | c_price |  c_parentrequest_id                               |

+--------+------------+---------+---------------------------------+

| pen    | 1          | 10      | 1177_purchaseRequition_purchase |

| pencil | 2          | 20      | 1177_purchaseRequition_purchase |

| SUM    | 3          | 30      | 1177_purchaseRequition_purchase |

+--------+------------+---------+---------------------------------+


Image RemovedImage Added

However, it does not actually play out well with the JDBC Binder data store as it is only expecting one parameter in the query. Our union query has 2 parameters.

...

Thai

อย่างไรก็ตามมันไม่ได้เล่นได้ดีกับ JDBC Binder data store เนื่องจากมันคาดหวังเพียงหนึ่งพารามิเตอร์ในแบบสอบถาม แบบสอบถามแบบร่วมของเรามี 2 พารามิเตอร์

เพื่อเอาชนะสิ่งนี้เราสามารถสร้างโพรซีเดอร์ที่เก็บไว้ในฐานข้อมูลแทน

Code Block
languagesql
DELIMITER //
CREATE PROCEDURE purchase_items_dataset
(IN recordId CHAR(255))
BEGIN
  select c_name, c_quantity, c_price,  c_parentrequest_id from app_fd_purchase_items where  c_parentrequest_id = recordId
union
select "SUM", sum(c_quantity), sum(c_price),  c_parentrequest_id from app_fd_purchase_items where  c_parentrequest_id = recordId;
END //
DELIMITER ;

With the stored procedure to return the appropriate dataset that we need, we will just need to call it from the JDBC Binderdata store.

Thai

ด้วยโพรซีเดอร์ที่เก็บไว้เพื่อส่งคืนชุดข้อมูลที่เหมาะสมที่เราต้องการเราจะต้องเรียกมันจาก JDBC Binderdata store

Image RemovedImage Added

This is the outcome.

Thai

นี่คือผลลัพธ์

Image RemovedImage Added