You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -61,24 +61,247 @@ To use on .Net Frameworks (4.5 ... 4.8) Install [DatatableJS.Net](https://www.nu
61
61
PM> Install-Package DatatableJS.Net
62
62
```
63
63
64
-
Using `.ToDataResult(request)` extension function with IQueryable collection, provides data can get with server side pagination very simply. To use this feature
65
-
install [DatatableJS.Data](https://www.nuget.org/packages/DatatableJS.Data/) from the package manager console:
64
+
Then add [datatables.net](https://datatables.net/) Javascript and CSS files or links to your project.
Set the URL to retrieve data from any action with GET or POST method:
72
+
73
+
```csharp
74
+
.URL(Url.Action("GetAll", "Person"), "POST")
75
+
```
76
+
Use `DataRequest` object to bind parameters of request. With `.ToDataResult(request);` extension method, if there is entity framework, execute IQueryable list server side from context. Otherwise manipulate data manually and return `DataResult<T>` object including data.
77
+
78
+
Install [DatatableJS.Data](https://www.nuget.org/packages/DatatableJS.Data/) from the package manager console:
Add additional filters before render datatable object. These filters are included in `.ToDataResult(request)` method with request while server side executing.
Using this method you can define which column(s) the order is performed upon, and the ordering direction. [Reference](https://datatables.net/reference/option/order)
128
+
```csharp
129
+
.Orders(order=> {
130
+
order.Add(p=>p.Name, OrderBy.Descending);
131
+
order.Add(p=>p.Age, OrderBy.Ascending);
132
+
})
133
+
```
134
+
## Length Menu
135
+
This method allows you to readily specify the entries in the length drop down _select_ list that DataTables shows . [Reference](https://datatables.net/reference/option/lengthMenu)
136
+
```csharp
137
+
.LengthMenu(newint[] {5,10,15})
138
+
```
139
+
Set _hasAll_ paramter true to show All option in select.
140
+
```csharp
141
+
.LengthMenu(newint[] {5,10,15}, true)
142
+
```
143
+
Set _allText_ paramter to change name of option All.
144
+
```csharp
145
+
.LengthMenu(newint[] {5,10,15}, true, "All Pages")
146
+
```
147
+
## Page Length
148
+
Number of rows to display on a single page when using pagination. [Reference](https://datatables.net/reference/option/pageLength)
149
+
```csharp
150
+
.PageLength(15)
151
+
```
152
+
## Name
153
+
Calling datatable on client-side is possible with name:
154
+
```csharp
155
+
.Name("GridName")
156
+
```
157
+
Default name is "DataGrid". If there are multiple grid in single page, different names should be given. Call grid if you need like this:
158
+
```javascript
159
+
$(document).ready(function() {
160
+
var table =$('#DataGrid').DataTable();
161
+
} );
162
+
```
163
+
## Searching
164
+
This option allows the search abilities of DataTables to be enabled or disabled. Default is "true". [Reference:](https://datatables.net/reference/option/searching)
165
+
```csharp
166
+
.Searching(false)
167
+
```
168
+
## Ordering
169
+
Enable or disable ordering of columns - it is as simple as that! DataTables, by default, allows end users to click on the header cell for each column, ordering the table by the data in that column. Default is "true". [Reference:](https://datatables.net/reference/option/ordering)
170
+
```csharp
171
+
.Ordering(false)
172
+
```
173
+
## Paging
174
+
DataTables can split the rows in tables into individual pages, which is an efficient method of showing a large number of records in a small space. The end user is provided with controls to request the display of different data as the navigate through the data. Default is "true". [Reference:](https://datatables.net/reference/option/paging)
175
+
```csharp
176
+
.Paging(false)
177
+
```
178
+
## Processing
179
+
Enable or disable the display of a 'processing' indicator when the table is being processed. Default is true. [Reference:](https://datatables.net/reference/option/processing)
180
+
```csharp
181
+
.Processing(false)
182
+
```
183
+
## ScrollX
184
+
Enable horizontal scrolling. When a table is too wide to fit into a certain layout, or you have a large number of columns in the table, you can enable horizontal (x) scrolling to show the table in a viewport, which can be scrolled. [Reference:](https://datatables.net/reference/option/scrollX)
185
+
```csharp
186
+
.ScrollX(true)
187
+
```
188
+
## Class
189
+
Default table css class is `"display nowrap dataTable dtr-inline collapsed"`. It can be replaced with other table class like bootstrap "table table-striped".
190
+
```csharp
191
+
.Class("table table-striped")
192
+
```
193
+
## Captions
194
+
Adding some text on table header or footer with Captions method that:
FixedColumns provides the option to freeze one or more columns to the left or right of a horizontally scrolling DataTable. [Reference:](https://datatables.net/reference/option/fixedColumns)
201
+
```csharp
202
+
.FixedColumns(leftColumns: 1, rightColumns: 3)
203
+
```
204
+
## Individual Column Searching
205
+
With this feature, data is be searchable column by column if column searchable is not false.
206
+
207
+
```csharp
208
+
.ColumnSearching(true)
209
+
```
210
+
To give class for these inputs:
211
+
212
+
```csharp
213
+
.ColumnSearching(true, "form-control")
214
+
```
215
+
## Title
216
+
Set column header. Default is property name.
217
+
```
218
+
.Title("Person Name");
219
+
```
220
+
Or use `DisplayAttribute` for properties.
221
+
```csharp
222
+
[Display(Name="Person Name")]
223
+
publicstringName { get; set; }
224
+
```
225
+
## Format
226
+
Customize datetime format with [Moment.js](https://momentjs.com/) expression.
227
+
```csharp
228
+
.Format("DD-MMM-Y");
229
+
```
230
+
Or use `DisplayFormatAttribute` for properties.
231
+
```csharp
232
+
[DisplayFormat(DataFormatString="DD-MMM-Y")]
233
+
publicDateTime?BirthDate { get; set; }
234
+
```
235
+
## Template
236
+
Manipulate and change display of column according to data.
Default language is English. You can change with other languages or custumize it. Set json url parameter to Language method for other languages from [CDN](https://datatables.net/plug-ins/i18n/).
78
272
79
-
Then add [datatables.net](https://datatables.net/) Javascript and CSS files or links to your project.
0 commit comments