I comment out and the result it´s the same, paste my code.
private void FormConsumos_Load(object sender, EventArgs e)
{
// GridSettings();
//ClientesCN clientesCN = new ClientesCN();
//List<Cliente> clientes = clientesCN.ClientesconVentas();
List<Clientes1> clientes = (from c in datos.Cliente
join f in datos.FacturaCliente
on c.NumCliente equals f.Cliente
join z in datos.Zona
on c.Codzona equals z.Codzona
select new Clientes1
{
NumCliente = c.NumCliente,
Nombre = c.Nombre,
Telefono = c.Telefono,
Movil = c.Movil,
Poblacion = c.Poblacion,
Provincia = c.Provincia,
Zona = z.Descripcion,
Comercial = c.Comercial,
Direccion = c.Direccion
}
).Distinct().ToList();
//Localizacion loc = new Localizacion();
//loc.getstring(true, true, true, true);
//LocalizationProvider.Provider = loc;
int totalclientes = clientes.Count();
// grid.TableOptions.ColumnsMaxLengthStrategy = GridColumnsMaxLengthStrategy.FirstNRecords;
IEnumerable clienteejem = clientes.Take(10);
IEnumerable orderDetailSamples = (from p in datos.Vista_Consumo_Clientes select p).Take(10);
PassThroughGroupingResult ListadoFacturas = new PassThroughGroupingResult(
"Clientes",
clientes,
typeof(Clientes1),
totalclientes,
clienteejem,
new UpdateHelper()
);
PassThroughGroupingResult orderDetailResults = new PassThroughGroupingResult(
"Pruebas",
new NestedQueryResultsDelegate(this.GetOrderDetailForOrder),
typeof(Pruebas),
orderDetailSamples
);
grid.SourceListSet.Add("Clientes", ListadoFacturas);
grid.SourceListSet.Add("Articulos", orderDetailResults);
grid.DataSource = ListadoFacturas;
grid.ShowGroupDropArea = true;
grid.AllowProportionalColumnSizing = true;
grid.TableDescriptor.Relations.Clear();
GridRelationDescriptor orders = new GridRelationDescriptor("Articulos");
orders.RelationKind = RelationKind.RelatedMasterDetails;
orders.RelationKeys.Add("NumCliente", "NumCliente");
orders.ChildTableName = "Articulos";
orders.ChildTableDescriptor.Relations.Clear();
grid.TableDescriptor.AllowNew = false;
grid.TableDescriptor.AllowEdit = false;
grid.TableDescriptor.AllowRemove = false;
//grid.TableDescriptor.Columns["NumCliente"].HeaderText = "Nº Cliente";
//grid.TableDescriptor.Columns["Nombre"].HeaderText = "Nombre";
//grid.TableDescriptor.Columns["Poblacion"].HeaderText = "Poblacion";
//grid.TableDescriptor.Columns["Provincia"].HeaderText = "Provincia";
//grid.TableDescriptor.Columns["Telefono"].HeaderText = "Teléfono";
//grid.TableDescriptor.Columns["Movil"].HeaderText = "Móvil";
//grid.TableDescriptor.Columns["Zona"].HeaderText = "Zona";
grid.TableDescriptor.Relations.Add(orders);
grid.TopLevelGroupOptions.ShowFilterBar = true;
grid.GridGroupDropArea.DragColumnHeaderText = "Arrastre el encabezado para agrupar.";
grid.NestedTableGroupOptions.ShowFilterBar = true;
grid.ChildGroupOptions.ShowFilterBar = true;
//Enable the filter for each columns
grid.TableDescriptor.Name = "Clientes";
for (int i = 0; i < grid.TableDescriptor.Columns.Count; i++)
grid.TableDescriptor.Columns[i].AllowFilter = true;
this.grid.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended;
this.grid.UseDefaultsForFasterDrawing = true;
this.grid.TopLevelGroupOptions.ShowFilterBar = true;
this.grid.ChildGroupOptions.ShowFilterBar = true;
//GridSummaryColumnDescriptor scd = new GridSummaryColumnDescriptor("Sum", SummaryType.Int32Aggregate, "Cantidad", "{Sum:#}");
//GridSummaryRowDescriptor srd = new GridSummaryRowDescriptor("Sum", "Total", scd);
//srd.Appearance.AnyCell.HorizontalAlignment = GridHorizontalAlignment.Right;
//srd.Appearance.AnyCell.BackColor = SystemColors.Info;
//grid.GetTableDescriptor("Articulos").SummaryRows.Add(srd);
//grid.GetTableDescriptor("Articulos").AllowEdit = false;
//grid.GetTableDescriptor("Articulos").AllowNew = false;
//grid.GetTableDescriptor("Articulos").AllowRemove = false;
//grid.GetTableDescriptor("Articulos").Columns[0].Width = 150;
//grid.GetTableDescriptor("Articulos").Columns[1].Width = 370;
//grid.GetTableDescriptor("Articulos").Columns[2].Width = 80;
//grid.GetTableDescriptor("Articulos").Columns[3].Width = 80;
//GridTableDescriptor gtd = grid.GetTableDescriptor("Articulos");
//GridConditionalFormatDescriptor Descriptor1 = new GridConditionalFormatDescriptor();
//Descriptor1.Appearance.AnyRecordFieldCell.TextColor = System.Drawing.Color.Red;
//Descriptor1.Expression = "[Cantidad] < 0";
//gtd.ConditionalFormats.Add(Descriptor1);
////GridSummaryColumnDescriptor prizeAvgSummary = new GridSummaryColumnDescriptor(
//// "Precio",
//// SummaryType.Custom,
//// "UnitPrice",
//// "{PrizeAvg:#.##}"
//// );
////orderDetail.ChildTableDescriptor.SummaryRows.Add(
//// new GridSummaryRowDescriptor("Row 1", prizeAvgSummary)
//// );
////orderDetail.ChildTableDescriptor.TopLevelGroupOptions.CaptionText =
//// "{TableName}: {RecordCount} Items, Average UnitPrice is {Row 1.PrizeAvgSummary}";
////orders.ChildTableDescriptor.Relations.Add(orderDetail);
////GridTableDescriptor tabd = grid.GetTableDescriptor("ArticuloFacturaCliente");
//grid.AddGroupDropArea("Clientes");
//grid.AddGroupDropArea("Articulos");
filter.WireGrid(grid);
}
public IEnumerable GetOrdersForCustomer(object[] keys, out object totals)
{
var orderQuery =
from p in datos.FacturaCliente
where p.Cliente.Equals(keys[0])
select p
;
totals = orderQuery.Count();
return orderQuery;
}
public IEnumerable GetOrderDetailForOrder(object[] keys, out object totals)
{
var precios = from f in datos.Vista_Consumo_Clientes
where f.NumCliente == keys[0].ToString()
orderby f.Cantidad descending
select new Pruebas
{
Referencia = f.Referencia,
Descripcion = f.Descripcion,
Cantidad = Convert.ToDecimal(f.Cantidad),
Precio = Convert.ToDecimal(f.precio)
}
;
totals = precios.Count();
return precios;
}