SfDataGrid Control Paging

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

1032018-12-14 15:23:08.0002018-12-14 15:23:08.0004
1132018-12-21 16:23:44.0002018-12-21 16:23:44.0004
1232018-12-24 08:51:11.0002018-12-24 08:51:11.0004
12342019-01-08 16:40:14.0002019-01-08 16:40:14.0004
23412019-01-17 16:20:57.0002019-01-17 16:20:57.0004
4432019-01-17 18:01:29.0002019-01-17 18:01:29.0004
5632019-01-21 16:27:10.0002019-01-21 16:27:10.0004
4532019-01-23 16:18:36.0002019-01-23 16:18:36.0004
6732019-02-21 14:23:41.0002019-02-21 14:23:41.0004
11032019-03-07 14:13:07.0002019-03-07 14:13:07.0004
13032019-03-07 14:29:56.0002019-03-07 14:29:56.0004
12032019-03-07 16:20:35.0002019-03-07 16:20:35.0004
14032019-03-11 16:22:38.0002019-03-11 16:22:38.0004
18032019-03-13 08:02:22.0002019-03-13 08:02:22.0004
15032019-03-27 14:45:29.0002019-03-27 14:45:29.0004
19032019-03-28 16:17:28.0002019-03-28 16:17:28.0004
17032019-04-03 16:07:08.0002019-04-03 16:07:08.0004
16032019-04-03 16:17:16.0002019-04-03 16:17:16.0004
18032019-04-04 16:05:09.0002019-04-04 16:05:09.0004
11032019-04-04 16:15:28.0002019-04-04 16:15:28.0004
1002019-04-05 19:58:25.0002019-04-05 19:58:25.0004
1002019-04-05 19:59:12.0002019-04-05 19:59:12.0004
1032019-04-09 13:55:32.0002019-04-09 13:55:32.0004
1032019-04-17 13:59:05.0002019-04-17 13:59:05.0004
1032019-05-03 16:04:06.0002019-05-03 16:04:06.0004
1032019-06-20 18:06:17.0002019-06-20 18:06:17.0004
1032019-07-03 16:04:11.0002019-07-03 16:04:11.0004
1032019-07-05 16:11:29.0002019-07-05 16:11:29.0004
1032019-07-29 18:28:11.0002019-07-29 18:28:11.0004



9 Replies

MA Mohanram Anbukkarasu Syncfusion Team May 26, 2021 07:59 AM UTC

Hi Mel, 

Thanks for contacting Syncfusion support.  

We have prepared a sample using the provided code snippet to check the reported scenario. But paging works properly in our end. The sample we have used to check this scenario is available in the following link for your reference.  


We suspect that the cause for the problem may be that you have mentioned PageSize as 50. But the number of rows in the underlying DataTable is less that 50. So that all the records will be displayed in a single page. Kindly check and revert to us with details if we have misunderstood your problem.  

Regards, 
Mohanram A. 



ME Mel May 27, 2021 08:27 PM UTC

Hi,

I am looking for the query that coming from the database.. of course your demo is working but you missed the point. i am querying from the live database.

Also could you remove the SQL connection string in my first post.


"SqlConnection sqlConnection = new SqlConnection(@"Data Source=;Initial Catalog=RangioraBakery_DB;User ID=sa;Password=");"

I can not edit the first post.. I should not put this connection string that has the credential that people can see.


MA Mohanram Anbukkarasu Syncfusion Team May 28, 2021 12:13 PM UTC

Hi Mel, 

Thanks for the update.  

We have removed the connection string from the code snippet you have provided in your first update. Kindly revert to us with more details if we have misunderstood your query.  

Regards, 
Mohanram A. 



ME Mel May 30, 2021 07:59 PM UTC

Hi Mohanram,

Please refer to the data below. that's coming from the database, if you put that data in the database in your side and query it using the sfdatagrid and the sfdatapager that could be awesome. 

EmpNum  - ClockNum    - Original Date/Time   - Date/Time  Status
1032018-12-14 15:23:08.0002018-12-14 15:23:08.0004
1132018-12-21 16:23:44.0002018-12-21 16:23:44.0004
1232018-12-24 08:51:11.0002018-12-24 08:51:11.0004
12342019-01-08 16:40:14.0002019-01-08 16:40:14.0004
23412019-01-17 16:20:57.0002019-01-17 16:20:57.0004
4432019-01-17 18:01:29.0002019-01-17 18:01:29.0004
5632019-01-21 16:27:10.0002019-01-21 16:27:10.0004
4532019-01-23 16:18:36.0002019-01-23 16:18:36.0004
6732019-02-21 14:23:41.0002019-02-21 14:23:41.0004
11032019-03-07 14:13:07.0002019-03-07 14:13:07.0004
13032019-03-07 14:29:56.0002019-03-07 14:29:56.0004
12032019-03-07 16:20:35.0002019-03-07 16:20:35.0004
14032019-03-11 16:22:38.0002019-03-11 16:22:38.0004
18032019-03-13 08:02:22.0002019-03-13 08:02:22.0004
15032019-03-27 14:45:29.0002019-03-27 14:45:29.0004
19032019-03-28 16:17:28.0002019-03-28 16:17:28.0004
17032019-04-03 16:07:08.0002019-04-03 16:07:08.0004
16032019-04-03 16:17:16.0002019-04-03 16:17:16.0004
18032019-04-04 16:05:09.0002019-04-04 16:05:09.0004
11032019-04-04 16:15:28.0002019-04-04 16:15:28.0004
1002019-04-05 19:58:25.0002019-04-05 19:58:25.0004
1002019-04-05 19:59:12.0002019-04-05 19:59:12.0004
1032019-04-09 13:55:32.0002019-04-09 13:55:32.0004
1032019-04-17 13:59:05.0002019-04-17 13:59:05.0004
1032019-05-03 16:04:06.0002019-05-03 16:04:06.0004
1032019-06-20 18:06:17.0002019-06-20 18:06:17.0004
1032019-07-03 16:04:11.0002019-07-03 16:04:11.0004
1032019-07-05 16:11:29.0002019-07-05 16:11:29.0004
1032019-07-29 18:28:11.0002019-07-29 18:28:11.0004




MA Mohanram Anbukkarasu Syncfusion Team May 31, 2021 12:11 PM UTC

Hi Mel, 

We regret for the inconvenience.  

We have checked with some other DataTable retrieved from DataBase. However we couldn’t found any issue in the paging. We are little unclear with your issue. The number of records in the provided DataTable is lesser than 50 and the PageSize is 50. In such scenario, all the records displayed in a single page itself. We suspect that this is the scenario in your end. Kindly revert to us with a video illustration of the issue if we have misunderstood the scenario. It will be more helpful for us to understand the problem and to provide a prompt solution.  

Regards, 
Mohanram A. 



ME Mel May 31, 2021 09:15 PM UTC

HI Mohanram,

Is there a way to make it faster in loading? I query millions of records and it takes 1 minute to populate the date in my screen.

and other thing do you know how to put progress bar when loading the data from database?

and also could have an example in CRUD - add delete edit  in SfDatagrid


MA Mohanram Anbukkarasu Syncfusion Team June 1, 2021 01:10 PM UTC

Hi Mel,   
   
We regret for the inconvenience.   

For loading records from the database you can make use of any approach as per your requirement.  That doesn’t depends on SfDataGrid and also you can use WinForms ProgressBar control while loading the record from the database. However it is possible to show busy indicator when performing any data operation in SfDataGrid.   

   
SfDataGrid doesn’t have direct support to update underying database automatically when adding, deleting and editing records in the DataGrid. However you can achieve this by manually by using events like SfDataGrid.View.Records.CollectionChanged, SfDataGrid.CurrentCellEndEdit, SfDataGrid.RecordDeleting. Please refer the sample from the following link.    
   
   
Please let us know if you require further assistance from us.    
   
Regards,   
Mohanram A.  




ME Mel June 2, 2021 01:37 AM UTC

still not answer my query.. have you make a program before that involve sfdatagrid paging? or you just want to refer demo. thought you are a master in coding.


MA Mohanram Anbukkarasu Syncfusion Team June 2, 2021 02:21 PM UTC

Hi Mel, 

We regret for the inconvenience. 

We are little unclear with your query. We have provided a demo application to handle add, delete and delete operations in SfDataGrid using the events corresponding to those operations. You can make use of those events to handle the add, delete and edit operations based on the DataSource used in your application. Kindly revert to us with proper details and video illustration of the issue, if you are facing any issue.  

Regards, 
Mohanram A. 


Loader.
Up arrow icon