Angular Material Tutorial - 27 - Data table
Summary
TLDRفي هذا الفيديو، نستعرض كيفية تنفيذ جدول بيانات أساسي باستخدام Angular Material. نبدأ بإستيراد الوحدة النمطية 'MatTableModule' ضمن 'material.module.ts'. ثم نتبع بنسخ ولصق كود لجدول بيانات أساسي من وثائق Material، شاملاً HTML، TypeScript، وCSS. نوضح كيفية تجهيز مصدر البيانات وربطه بالجدول، تعريف قوالب الأعمدة وأخيرًا، تحديد الصفوف والعناوين. نهدف إلى تزويد المشاهدين بفهم شامل لتنفيذ جدول بيانات في Angular Material، مع التركيز على الخطوات الأساسية من تعريف مصدر البيانات إلى عرض الصفوف والأعمدة.
Takeaways
- 📌 الخطوة الأولى في إنشاء جدول بيانات أساسية في Angular Material هي استيراد المودول.
- 🔍 من خلال استيراد مודول mat table وإضافة Material_ARRAY، يمكننا تضمين جدول البيانات في التطبيق.
- 💡 نقوم بنسخ الشفرة لجدول البيانات الأساسية من وثائق Angular Material لتوفير الوقت والفهم.
- 📝 يتم تحديد النوع لكل عنصر في جدول البيانات من خلال تصنيف العناصر الدورية.
- 🔢 يتم تحديد العناصر الأساسية التي سيتم عرضها في الجدول بواسطة صف الرأس والصفوف.
- 🎨 يتم استخدام ng container لتحديد العناصر التي لن تظهر في DOM ولكنها توفر عنصر لتطبيق mat column def.
- 🏗️ يتم تكوين الرأس والصفوف في HTML باستخدام mat-header-row و mat-row مع استخدام mat-columnDefs.
- 🔑 يتم استخدام الربط الوظيفي (property binding) لربط مصدر البيانات مع الجدول في HTML.
- 📊 يتم استخدام التكرار (iteration) لاسترداد صفوف الجدول من مصدر البيانات وربطها بالتخطيطات المخصصة.
- 📈 يمكن استخدام التكرار وструктур التوجيه (structural directives) لعرض الرأس والخلايا الأساسية للجدول.
- 🚀 بمجرد تشغيل الكود، يجب أن نرى الجدول البيانات يعمل كما يتوقع، مع الرأس والصفوف المطلوبين.
Q & A
الخطوة الأولى لإنشاء جدول بيانات أساسي في Angular Material ما هي؟
-الخطوة الأولى لإنشاء جدول بيانات أساسي في Angular Material هي استيراد المودول، حيث نقوم باستيراد mat-table مodule من material dot module dot es.
ماذا نقوم به بعد استيراد المودول؟
-بعد استيراد المودول، ننسخ الشفرة لجدول البيانات الأساسية ونتفهم الأجزاء المختلفة التي تتحمل العمل của جدول البيانات.
كيف يمكننا العثور على المثال اللازم؟
-يمكننا العثور على المثال اللازم في مستند Material، بالانتقال إلى قسم الكونponents ثم إلى قسم الجدول البيانات والنقر على الرابط في علامة التبويب الأمثلة.
ما هي الخطوة التالية بعد نسخ الشفرة؟
-الخطوة التالية بعد نسخ الشفرة هي فهم الأجزاء المختلفة التي تشكل الجدول البيانات وكيف تعمل.
ما هي المصادر اللازمة لإنشاء جدول البيانات؟
-المصادر اللازمة لإنشاء جدول البيانات هي ال数据源، التي تتضمن البيانات التي سيتم عرضها في الجدول.
كيف نوفر هذه المصادر اللازمة للجدول؟
-نحن نوفر هذه المصادر اللازمة للجدول في HTML، من خلال إنشاء جدول بيانات باستخدام mat table component واستخدام صفحة الربط لربط الملكية الموجودة في الفصل العلوي.
ماذا تعني ال的定义 ال軒 لجدول البيانات؟
-تعني التعريف ال軒 للجدول البيانات تعريف ال軒 ال数据، حيث نستخدم الNG container element لتطبيق mat column def directive، وال.directive يحدد ال軒 بشكل فريد.
كيف نعرض ال軒 والصفوف في الجدول؟
-لعرض ال軒 والصفوف في الجدول، نستخدم mat header row component و mat row component، و نستخدم mat header row def و mat row def directives لتحديد ال軒 والصفوف التي سيتم عرضها.
كيف نقوم باسترداد البيانات من ال軒 والصفوف؟
-نستخدم تكرارية لاسترداد الصفوف، ونحصل على مرجع لكل صف، ونستخدم التكسير لربط البيانات مع الرأي.
ما هي الخطوات الثلاثة لإنشاء جدول بيانات أساسي في Angular Material؟
-الخطوات الثلاثة لإنشاء جدول بيانات أساسي في Angular Material هي: تعريف ال数据源 وال軒 المطلوبة، تعريف ال軒 ال軒 التعريفي، وإضافة ال軒 والصفوف.
ماذا سنقوم به في الفيديو القادم؟
-في الفيديو القادم، سنقوم بإجراء بعض التغييرات وسنرى كيف يؤثر ذلك على جدول البيانات، مما سيمنحك فكرة أفضل عن كيفية العملของ الجدول البيانات.
Outlines
📝 Implementing a Basic Data Table in Angular Material
This paragraph introduces the process of implementing a basic data table in Angular Material. It begins by emphasizing the importance of importing the necessary module, the MatTableModule, and the MatArray module. The paragraph then suggests copying a basic data table code example from the official documentation to understand the different parts responsible for the functioning of a data table. The example uses display flex and provides a step-by-step guide on copying the HTML, TypeScript, and CSS code snippets into their respective component files. The paragraph also explains the importance of having a data source and how to bind it to the table using property binding in the HTML. It introduces the concept of defining an interface for the data structure and an array of elements that conform to this interface. The paragraph concludes by explaining the role of the data source, interface, and array in the data table implementation process.
🛠️ Defining Column Templates and Row Definitions
This paragraph delves into the specifics of defining column templates and row definitions for the data table. It explains the purpose of the ng container element and the matColumnDef directive, which uniquely identifies a column with a key. The paragraph highlights the use of the matHeaderCellDef and matCellDef structural directives to define how the header and data cells are displayed, respectively. It also discusses the process of iterating through the data rows, accessing their properties, and binding the data to the view using interpolation. The paragraph further clarifies the role of the matHeaderRow and matRow components in defining the table header row and data rows, and how the displayedColumns property is used to determine which columns are shown in the table. The summary emphasizes the three-step process of implementing a data table in Angular Material: defining the data source and columns, creating column templates, and including header and row definitions. It concludes by mentioning that the next video will explore making changes to the data table to provide a better understanding of its workings.
Mindmap
Keywords
💡Angular Material
💡Data Table
💡Interface
💡Data Source
💡Property Binding
💡Column Templates
💡Structural Directives
💡Interpolation
💡Mat Header Cell
💡Mat Cell
💡Flex Layout
Highlights
Importing the Angular Material module to implement a basic data table.
Saving time by copying the code for a basic data table from the Angular Material documentation.
Understanding the different parts responsible for the functioning of a data table.
Creating a data source with an array of periodic elements and an interface defining each element's type.
Declaring the interface and data array outside the component for reusability.
Initializing the data source property with element data array.
Providing the data source to the data table using property binding in the HTML.
Defining column templates for the position, name, weight, and symbol columns using ng-container elements.
Using mat-column-def directive to uniquely identify columns with a key.
Applying mat-header-cell and mat-cell components for styling header and data cells without attaching any styling to the elements themselves.
Accessing each row of the data source and binding the data to the view using interpolation.
Iterating through the rows, accessing properties, and displaying them in the column templates.
Defining the table header row with mat-header-row component and specifying displayed columns.
Displaying data rows with mat-row component and exporting a variable containing the data of each row.
Summarizing the three steps in implementing a data table in Angular Material: defining the data source and columns, column templates, and header and row definitions.
Creating a basic data table without writing any new code, and planning to make changes in the next video for a better understanding of the data table's functionality.
Transcripts
all right in this video let's take a
look at implementing a basic data table
in angular material the first step as
always is to import the module so in
material dot module dot es import mat
table module and added to the material
array
now what we are going to do to save us
some time is copy the code for a basic
data table and then understand the
different parts that are responsible for
the functioning of a data table so in
the material Doc's go to components and
then to the data table section and click
on the table link over here in the
examples tab we have a basic data table
now go to the second example
which is basic use of math table and
uses display flex and click on the code
icon now let's copy paste the code first
the HTML so copy and paste it in AB
component dot HTML next the typescript
file so go to TS copy the interface and
the data in AB component TS paste it
right after the import statement then go
back to the documentation and copy the
two lines of code from the component
class go back to BS code and in app
component paste them finally copy the
CSS so we're here CSS and then copy this
and paste it in AB component dot CSS now
if we save all the files and take a look
at the browser you should be able to see
a data table now let's understand the
different parts that make up this data
table the first part to implementing a
data table is the data source every data
table needs a data source that contains
the data to be displayed in our example
we have the data of periodic elements we
have an interface that defines the type
of
each element so a periodic element will
have a name position rate and symbol
right below the interface is where you
see the array of periodic elements we
have ten elements each having properties
mentioned in the interface what you have
to notice here is that the interface and
the data array is declared outside the
component to be able to use it in the
component we need to create a property
and initialize it for that purpose we
have data source which is initialized to
element data this array right here
alright the next thing to do is to
provide this data source to the data
table and we do that in the HTML so in
am dot component dot HTML we create a
data table with mat table component and
to provide the data source they make use
of the data source attribute we use
property binding to bind the property
defined in the component class so data
source is equal to element data which is
provided here so that is the first step
to implementing a data table creating
the data source and binding it to the
table the second step is to define the
column templates in the browser you can
see that we have four columns the
position number name weight and symbol
in the code we define the four columns
each inside its own ng container element
physician name weight and symbol the ng
container element will not be rendered
to the Dom but it will provide an
element for applying this mat column def
directive the mat column death directive
is what uniquely identifies a given
column with a key physician named way
and symbol inside the ng container
element we will have all the
configuration for a given column you can
see that we have the template that
defines how to display the header for a
given column identified using the map
header cell death structural directive
we also have another template that
defines how to display the data cells of
a given column using the mat cell def
structural directive the to structural
directives do not attach any styling to
the elements the styling is taken care
of by mat header cell and mat cell
components next let's talk about the
content of the heading and the data
cells for the heading you can see that
we just have static text number name
weight and symbol but for the data cell
we get access to each row of the data
source we obtain a reference to each row
and then access the different properties
of each row we then use interpolation to
bind the data to the view so in our data
source we have ten rows we iterate
through the rows get a reference to each
row and store it in the element variable
and then we access the appropriate
property in the column template so
element dot position dot name dot weight
in dot symbol these are the different
properties for each element
all right now what we have done so far
is just define the column template how
it's supposed to look the final step is
to define the rows in the data table and
for that we make use of two more
components to define the table header
row we make use of the mat header row
component and to determine which columns
have to be displayed in the table mat
header row death structural directive is
used to this we assign displayed columns
property which is an array of columns we
have mentioned in the component class so
display columns is an array of strings
with positioned name weight and symbol
similarly to display the data rows we
make use of the mat rope component now
with mat Perot death structural
directive we also have a variable
exported that we have named as row
containing the data of that given row
and we have to specify the columns
property which contains the order in
which the data cells should be rendered
again this is displayed columns property
so when you run this code we should have
the data table working as expected
position name weight and symbol and then
the different rows corresponding to each
entry or each item in the element array
so to summarize there are three steps in
implementing a data table in angular
material first up define the data source
and the columns to be displayed second
step define the column templates and
finally the third step include the
header and the row definitions so we are
able to create a very basic data table
we copy pasted the code and did not
really code anything as such so in the
next video let's also try to make some
changes and see how that impacts the
data table that will give you guys a
much better idea of how the data table
works I will see you guys in the next
video
5.0 / 5 (0 votes)
Angular Material Tutorial - 1 - Introduction
Merge Models Locally While Fine-Tuning on Custom Data Locally - LM Cocktail
Angular Material Tutorial - 8 - Badges
Hugging Face GGUF Models locally with Ollama
ESP32 precision GPS receiver (incl. RTK-GPS Tutorial). How to earn money with it (DePIN)
Yes! I Finally Did It | 0 to 102 BROKE FC (Episode 5) - FC MOBILE