public void SetRowstoGenerate(int count){BookRepository bookrepository = new BookRepository();bookInfo = bookrepository.GetBookDetails(count);}
public List<PolizaElementoBO> polizaElementos;private ObservableCollection<PolizaElementoInfo> polizaInfo;public ObservableCollection<PolizaElementoInfo> PolizaInfoCollection{get { return polizaInfo; }set { this.polizaInfo = value; }}public PolizaElementoInfoRepository(List<PolizaElementoBO> data){this.polizaElementos = data;polizaInfo = new ObservableCollection<PolizaElementoInfo>();this.GeneratePolizaElementos(this.polizaElementos);}private void GeneratePolizaElementos(List<PolizaElementoBO> datos){ProductoBM productoManager = new ProductoBM();foreach (var dato in datos){if (dato.Texto1 == null){dato.Texto1 = "No";}if (dato.Texto2 == null){dato.Texto2 = "No";}if (dato.Texto3 == null){dato.Texto3 = "No";}var producto = productoManager.queryProductoWithId(dato.ProductoPrecio.IdProducto);polizaInfo.Add(new PolizaElementoInfo(producto.Clave, producto.Sku, producto.Nombre, dato.Referencias, dato.Cantidad1, dato.Cantidad2, dato.Cantidad3, dato.Precio1, dato.Precio2, dato.Precio3, dato.Texto1, dato.Texto2, dato.Texto3));}}
public class ViewModel()
{
PolizaElementoInfoRepository collection; public ViewModel()
{
collection = new PolizaElementoInfoRepository(data);
polizaInfo = collection.PolizaInfoCollection;
}
private ObservableCollection<PolizaElementoInfo> polizaInfo;
public ObservableCollection<PolizaElementoInfo> PolizaInfoCollection
{
get { return polizaInfo; }
set { this.polizaInfo = value; }
}
} |
//Filtering.cs internal void OnFilterChanged() { if (this.SfGrid.View != null) { //Here we have used a predicate called Filter in order to display the filtered records. SfGrid.View.Filter = viewmodel.FilerRecords; SfGrid.View.RefreshFilter(); } } //ViewModel.cs //You can filter the records based your requirement public bool FilerRecords(object o) { double res; bool checkNumeric = double.TryParse(FilterText, out res); var item = o as PolizaElementoInfo; if (item != null && FilterText.Equals("")) { return true; } else { if (item != null) { if (checkNumeric && !SelectedColumn.Equals("All Columns") && SelectedCondition != "Contains") { bool result = MakeNumericFilter(item, SelectedColumn, SelectedCondition); return result; } else if (SelectedColumn.Equals("All Columns")) { if (item.BookID.ToString().ToLower().Contains(FilterText.ToLower())) return true; return false; } else { bool result = MakeStringFilter(item, SelectedColumn, SelectedCondition); return result; } } } return false; } |