Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Conexión con bases de datos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Conexión con bases de datos

 
 
Herramientas Buscar en Tema Desplegado
  #7  
Antiguo 25-03-2016
Avatar de pnsd_89
pnsd_89 pnsd_89 is offline
Miembro
 
Registrado: mar 2007
Posts: 112
Poder: 20
pnsd_89 Va por buen camino
Buenas yo uso un DBGridEh con DBxpert logro ordenar con el siguiente codigo:

Código Delphi [-]
procedure OrdenaDataSetGridEH(var CDS: TClientDataSet; Column: TColumnEH; var dbgPrin: TDBGridEH);
const
  idxDefault = 'DEFAULT_ORDER';
var
  strColumn : string;
  i : integer;
  bolUsed : boolean;
  idOptions : TIndexOptions;
begin

  strColumn := idxDefault;
  if Column.Field.FieldKind in [fkCalculated, fkLookup, fkAggregate, fkInternalCalc] then Exit;
  if Column.Field.DataType in [ftBlob, ftMemo] then Exit;
  //
  //for i := 0 to dbgPrin.Columns.Count -1 do
    //dbgPrin.Columns[i].Title.Font.Style := [];
  for i := 0 to dbgPrin.Columns.Count -1 do
    dbgPrin.Columns[i].Title.Font.Color := clNavy;

  //
  bolUsed := (Column.Field.FieldName = CDS.IndexName);
  //
  CDS.IndexDefs.Update;
  for i := 0 to CDS.IndexDefs.Count - 1 do
  begin
    if CDS.IndexDefs.Items[i].Name = Column.Field.FieldName then
    begin
      strColumn := Column.Field.FieldName;
      case (CDS.IndexDefs.Items[i].Options = [ixDescending]) of
         True : idOptions := [];
         False : idOptions := [ixDescending];
      end;
    end;
  end;
  //
  if (strColumn = idxDefault)  or (bolUsed) then
  begin
    if bolUsed then
      CDS.DeleteIndex(Column.Field.FieldName);
    try

      {Esto evita un error de Key Violation}
      if (idOptions <> [ixDescending])
      and (idOptions <> []) then
        idOptions := [];

      CDS.AddIndex(Column.Field.FieldName, Column.Field.FieldName, idOptions,'', '', 0);
      strColumn := Column.Field.FieldName;
    except
      if bolUsed then strColumn := idxDefault;
    end;
  end;
  //
  try
    CDS.IndexName := strColumn;
    Column.Title.Font.Color := clRed;
    Column.Title.Caption := Column.Title.Caption;
    Column.Title.Font.Style := [fsbold];
    CDS.First;
  except
    CDS.IndexName := idxDefault;
  end;
  //
end;

Ahora cuando a un CDS le creo un campo de tipo lookup el mismo no lo ordena y realmente ya he mirado mucho y no logro entender el porque
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 10:28:45.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi