Hi there,
Just need help about the SfDataGrid to have a paging and a filter.
I managed to display the data from the database using dataset but paging is not working and also I want to put search in it.. please refer to my screenshot.
in my code i tried to convert the dataset to list as the sfdatapager is limited to only display in list. I am not sure if there's is another way of getting the data from database to put into list so that i will not convert from dataset to list.
Code below,
DataSet dataSet = new DataSet();
sqlConnection.Open();
SqlDataAdapter sqlAdapter = new SqlDataAdapter("Select * from ClockTimes", sqlConnection);
sqlAdapter.Fill(dataSet, "ClockTimes");
this.sfDataGrid1.DataSource = dataSet.Tables["ClockTimes"];
var clockTimesData = dataSet.Tables[0].AsEnumerable().Select(r => new GetClockTimes
{
EmpNum = r.Field("EmpNum"),
ClockNum = r.Field("ClockNum")
});
var list = clockTimesData.ToList(); // For if you really need a List and not IEnumerable
sfDataPager1.PageCount = 5;
sfDataPager1.PageSize = 50;
//sfDataPager1.DataSource =
sfDataPager1.DataSource = list;
sfDataGrid1.DataSource = sfDataPager1.PagedSource;
Sample Data below
EmpNum - ClockNum - Original Date/Time - Date/Time Status
| 10 | 3 | 2018-12-14 15:23:08.000 | 2018-12-14 15:23:08.000 | 4 |
| 11 | 3 | 2018-12-21 16:23:44.000 | 2018-12-21 16:23:44.000 | 4 |
| 12 | 3 | 2018-12-24 08:51:11.000 | 2018-12-24 08:51:11.000 | 4 |
| 123 | 4 | 2019-01-08 16:40:14.000 | 2019-01-08 16:40:14.000 | 4 |
| 234 | 1 | 2019-01-17 16:20:57.000 | 2019-01-17 16:20:57.000 | 4 |
| 44 | 3 | 2019-01-17 18:01:29.000 | 2019-01-17 18:01:29.000 | 4 |
| 56 | 3 | 2019-01-21 16:27:10.000 | 2019-01-21 16:27:10.000 | 4 |
| 45 | 3 | 2019-01-23 16:18:36.000 | 2019-01-23 16:18:36.000 | 4 |
| 67 | 3 | 2019-02-21 14:23:41.000 | 2019-02-21 14:23:41.000 | 4 |
| 110 | 3 | 2019-03-07 14:13:07.000 | 2019-03-07 14:13:07.000 | 4 |
| 130 | 3 | 2019-03-07 14:29:56.000 | 2019-03-07 14:29:56.000 | 4 |
| 120 | 3 | 2019-03-07 16:20:35.000 | 2019-03-07 16:20:35.000 | 4 |
| 140 | 3 | 2019-03-11 16:22:38.000 | 2019-03-11 16:22:38.000 | 4 |
| 180 | 3 | 2019-03-13 08:02:22.000 | 2019-03-13 08:02:22.000 | 4 |
| 150 | 3 | 2019-03-27 14:45:29.000 | 2019-03-27 14:45:29.000 | 4 |
| 190 | 3 | 2019-03-28 16:17:28.000 | 2019-03-28 16:17:28.000 | 4 |
| 170 | 3 | 2019-04-03 16:07:08.000 | 2019-04-03 16:07:08.000 | 4 |
| 160 | 3 | 2019-04-03 16:17:16.000 | 2019-04-03 16:17:16.000 | 4 |
| 180 | 3 | 2019-04-04 16:05:09.000 | 2019-04-04 16:05:09.000 | 4 |
| 110 | 3 | 2019-04-04 16:15:28.000 | 2019-04-04 16:15:28.000 | 4 |
| 10 | 0 | 2019-04-05 19:58:25.000 | 2019-04-05 19:58:25.000 | 4 |
| 10 | 0 | 2019-04-05 19:59:12.000 | 2019-04-05 19:59:12.000 | 4 |
| 10 | 3 | 2019-04-09 13:55:32.000 | 2019-04-09 13:55:32.000 | 4 |
| 10 | 3 | 2019-04-17 13:59:05.000 | 2019-04-17 13:59:05.000 | 4 |
| 10 | 3 | 2019-05-03 16:04:06.000 | 2019-05-03 16:04:06.000 | 4 |
| 10 | 3 | 2019-06-20 18:06:17.000 | 2019-06-20 18:06:17.000 | 4 |
| 10 | 3 | 2019-07-03 16:04:11.000 | 2019-07-03 16:04:11.000 | 4 |
| 10 | 3 | 2019-07-05 16:11:29.000 | 2019-07-05 16:11:29.000 | 4 |
| 10 | 3 | 2019-07-29 18:28:11.000 | 2019-07-29 18:28:11.000 | 4 |