แค่เว็บๆหนึ่ง ! ที่อยากเก็บประสบการณ์
Home
 

Powerbuilder กับการ Sorting Datawindow

วันนี้ได้ลองโหลด PB12.5  มาทดลอง

เลยได้ Code มาแนะนำดังนี้

 

 

ก่อนอื่นต้อง กำหนดชื่อ Column header ให้เหมือนกับชื่อ Fields และ ต่อท้านด้วย    ‘_t

ตัวอย่าง  Column Name : ’emp_id’
ให้กำหนด  Column Header  เป็น  ’emp_id_t’  กำหนดเฉพาะ Column ที่ต้องการ

 

จากนั้นให้ใส่ Code ของ Event Clicked ดังนี้

String ls_old_sort, ls_column
Char lc_sort
/* Check whether the user clicks on the column header */
IF Right(dwo.Name,2) = '_t' THEN
 ls_column = LEFT(dwo.Name, LEN(String(dwo.Name)) - 2)
 /* Get old sort, if any. */
 ls_old_sort = dw_1.Describe("Datawindow.Table.sort")
 /* Check whether previously sorted column and currently clicked column are same or not. If both are same then check for the sort order of previously sorted column (A - Asc, D - Des) and change it. If both are not same then simply sort it by Ascending order. */
 IF ls_column = LEFT(ls_old_sort, LEN(ls_old_sort) - 2) THEN
 lc_sort = RIGHT(ls_old_sort, 1)
 IF lc_sort = 'A' THEN
 lc_sort = 'D'
 ELSE
 lc_sort = 'A'
 END IF
 dw_1.SetSort(ls_column+" "+lc_sort)
 ELSE
 dw_1.SetSort(ls_column+" A")
 END IF
 dw_1.Sort()
END IF
ที่มา : http://power-builder.blogspot.com/
Off 

September 4, 2012 This post was written by Categories: เรื่องเล่ารายวัน No comments yet


Top