In this article, one will learn on how to configure the Form element's Date Picker and on how it would affect other elements down the line based on the sample below.

The objective of this article is to configure everything that is related to date picker (date elements) to a single format, which is dd-mm-yyyy and to be able to sort records correctly using the same date element too.

ในบทความนี้เราจะเรียนรู้วิธีกำหนดค่าตัวใช้ Date Picker ขององค์ประกอบฟอร์มและวิธีที่จะมีผลกับองค์ประกอบอื่น ๆ ตามบรรทัดตามตัวอย่างด้านล่าง

วัตถุประสงค์ของบทความนี้คือการกำหนดค่าทุกอย่างที่เกี่ยวข้องกับตัวใช้เลือกวันที่ (องค์ประกอบวันที่) เป็นรูปแบบเดียวซึ่งเป็น dd-mm-yyyy และสามารถจัดเรียงระเบียนได้อย่างถูกต้องโดยใช้องค์ประกอบวันที่เดียวกัน



Figure 1: Form Date Picker Configurations

รูปที่ 1: การกำหนดค่าตัวใช้เลือกวันที่แบบฟอร์ม


Based on the configurations above on Date Picker, when one picks a date, (e.g. June 2, 2016), it will display 02-06-2016 to the user. This is because the Display Format is set to dd-mm-yy.

When the form is submitted, it will be stored as 2016-06-02 because the Data Format is set to yyyy-MM-dd.

ขึ้นอยู่กับการกำหนดค่าด้านบนตัวเลือก Date Picker เมื่อมีคนเลือกวันที่ (เช่น 2 มิถุนายน 2016) จะแสดงวันที่ 02-06-2016 แก่ผู้ใช้ นี่เป็นเพราะรูปแบบการแสดงผลถูกตั้งค่าเป็น dd-mm-yy

เมื่อส่งแบบฟอร์มมันจะถูกจัดเก็บเป็น 2016-06-02 เนื่องจากรูปแบบข้อมูลถูกตั้งค่าเป็น yyyy-MM-dd

Figure 2: Date Formatter Configurations

รูปที่ 2: การกำหนดค่าตัวจัดรูปแบบวันที่

When the form is submitted, it will be stored as 2016-06-02

When one view the records submitted in a Datalist, the date value shown will be based on the Data Format set earlier. Therefore, to make the date to show in our desired format, we will need to make use of the Date Formatter with the configurations as shown above.

Sorting based on this date column will work as sorting is based on data format, yyyy-MM-dd.

เมื่อมีใครดูบันทึกที่ส่งใน Datalist ค่าวันที่ที่แสดงจะเป็นไปตามชุดรูปแบบข้อมูลก่อนหน้านี้ ดังนั้นเพื่อให้วันที่แสดงในรูปแบบที่เราต้องการเราจะต้องใช้ประโยชน์จาก Date Formatter ด้วยการกำหนดค่าตามที่แสดงด้านบน

การเรียงลำดับตามคอลัมน์วันที่นี้จะทำงานตามการจัดเรียงตามรูปแบบข้อมูล yyyy-MM-dd

All form fields will be treated and saved as string/characters to maintain flexibility in form design.

เขตข้อมูลฟอร์มทั้งหมดจะได้รับการปฏิบัติและบันทึกเป็นสตริง / อักขระเพื่อรักษาความยืดหยุ่นในการออกแบบฟอร์ม

Figure 3: Date Range Filter Configurations

รูปที่ 3: การกำหนดค่าตัวกรองช่วงวันที่


Likewise, in order to make use of any filter (i.e. Date Range Filter) in relation to the date picker's form element, one should also configure the Display Format and Data Format according to the format first set in Date Picker itself as shown in the figure above.

ในทำนองเดียวกันเพื่อที่จะใช้ประโยชน์จากตัวกรองใด ๆ (เช่นตัวกรองช่วงวันที่) ที่เกี่ยวข้องกับองค์ประกอบแบบฟอร์มของตัวเลือกวันที่หนึ่งก็ควรกำหนดค่ารูปแบบการแสดงผลและรูปแบบข้อมูลตามรูปแบบที่กำหนดไว้ในตัวเลือกวันที่ ข้างบน.

Tutorial Video:

วิดีโอการสอน:

Sample App:

แอปตัวอย่าง:

Related Elements

องค์ประกอบที่เกี่ยวข้อง