Hi Team,
I am working on SFDatagrid with Pagination.
My Scenario is when the user click on the button the DataGrid data wants to refresh with proper pagination. For the first time when the page load the SFDataGrid is working with pagination. but when the user click on the button the pagination is not working
I did small sample and attaching to this. In the sample i have button and SFDatagrid. onload the Datagrid will be loaded with some sample data after loading click on the search button the data is refreshing but not displaying until clicking on the DataGrid headers and pagination is not at all working after button click. can you help me to solve this issue..
Thanks
Praveen.
| public class MainViewModel : BaseViewModel
{
public MainViewModel()
{
SearchCommand = new Command(async () =>
{
Search();
});
Get();
}
private void Search()
{
var collection = new ObservableCollection<OrderInfo>();
Random r = new Random();
var num = r.Next(100, 999);
this.GenerateOrders(num,collection);
OrderInfoCollection = collection;
}
private Command _searchCommand;
public Command SearchCommand
{
get { return _searchCommand; }
set { SetValue(ref _searchCommand, value); }
}
private ObservableCollection<OrderInfo> orderInfo;
public ObservableCollection<OrderInfo> OrderInfoCollection
{
get { return orderInfo; }
set { SetValue(ref orderInfo, value); }
}
private void Get()
{
var collection = new ObservableCollection<OrderInfo>();
Random r = new Random();
var num = r.Next(100, 999);
this.GenerateOrders(num, collection);
OrderInfoCollection = collection;
}
private int _pageSize;
public int PageSize
{
get { return _pageSize; }
set { SetValue(ref _pageSize, value); }
}
private void GenerateOrders(int num,ObservableCollection<OrderInfo> orderInfos)
{
orderInfos.Add(new OrderInfo(num + 1001, "Maria Anders", "Germany", "ALFKI", "Berlin"));
orderInfos.Add(new OrderInfo(num + 1002, "Ana Trujillo", "Mexico", "ANATR", "Mexico D.F."));
orderInfos.Add(new OrderInfo(num + 1003, "Ant Fuller", "Mexico", "ANTON", "Mexico D.F."));
orderInfos.Add(new OrderInfo(num + 1004, "Thomas Hardy", "UK", "AROUT", "London"));
orderInfos.Add(new OrderInfo(num + 1005, "Tim Adams", "Sweden", "BERGS", "London"));
orderInfos.Add(new OrderInfo(num + 1006, "Hanna Moos", "Germany", "BLAUS", "Mannheim"));
orderInfos.Add(new OrderInfo(num + 1007, "Andrew Fuller", "France", "BLONP", "Strasbourg"));
orderInfos.Add(new OrderInfo(num + 1008, "Martin King", "Spain", "BOLID", "Madrid"));
orderInfos.Add(new OrderInfo(num + 1009, "Lenny Lin", "France", "BONAP", "Marsiella"));
orderInfos.Add(new OrderInfo(num + 1010, "John Carter", "Canada", "BOTTM", "Lenny Lin"));
orderInfos.Add(new OrderInfo(num + 1011, "Laura King", "UK", "AROUT", "London"));
orderInfos.Add(new OrderInfo(num + 1012, "Anne Wilson", "Germany", "BLAUS", "Mannheim"));
orderInfos.Add(new OrderInfo(num + 1013, "Martin King", "France", "BLONP", "Strasbourg"));
orderInfos.Add(new OrderInfo(num + 1014, "Gina Irene", "UK", "AROUT", "London"));
orderInfos.Add(new OrderInfo(num + 1031, "Maria Anders", "Germany", "ALFKI", "Berlin"));
orderInfos.Add(new OrderInfo(num + 1032, "Ana Trujillo", "Mexico", "ANATR", "Mexico D.F."));
orderInfos.Add(new OrderInfo(num + 1033, "Ant Fuller", "Mexico", "ANTON", "Mexico D.F."));
orderInfos.Add(new OrderInfo(num + 1034, "Thomas Hardy", "UK", "AROUT", "London"));
orderInfos.Add(new OrderInfo(num + 1035, "Tim Adams", "Sweden", "BERGS", "London"));
orderInfos.Add(new OrderInfo(num + 1036, "Hanna Moos", "Germany", "BLAUS", "Mannheim"));
orderInfos.Add(new OrderInfo(num + 1037, "Andrew Fuller", "France", "BLONP", "Strasbourg"));
orderInfos.Add(new OrderInfo(num + 1038, "Martin King", "Spain", "BOLID", "Madrid"));
orderInfos.Add(new OrderInfo(num + 1039, "Lenny Lin", "France", "BONAP", "Marsiella"));
orderInfos.Add(new OrderInfo(num + 1030, "John Carter", "Canada", "BOTTM", "Lenny Lin"));
orderInfos.Add(new OrderInfo(num + 1031, "Laura King", "UK", "AROUT", "London"));
orderInfos.Add(new OrderInfo(num + 1032, "Anne Wilson", "Germany", "BLAUS", "Mannheim"));
orderInfos.Add(new OrderInfo(num + 1033, "Martin King", "France", "BLONP", "Strasbourg"));
orderInfos.Add(new OrderInfo(num + 1034, "Gina Irene", "UK", "AROUT", "London"));
PageSize = Convert.ToInt32(Math.Ceiling(orderInfos.Count / 10M));
}
|
HI Karthikraja Kalaimani
Thanks for the help.. It is working fine now.
I have one more query in datagrid, i am planning to add Sl No.(Serial Number) Column to Datagrid, While i am sending the SL No from the code it is displaying wrongly when the user click on any column sorting. so is there any functionality to set the serial number from the datagrid based on the pagination and also when the user click on column sorting it wants to work.