ClientDataSet - tudo sobre ele |
Top Previous Next |
* Criando agregados no clientdataset
1. Coloque no form: ClientDataSet, DataSetProvider, DataSource, DbGrid, Table ou Query 2. DataSetProvider.DataSet := Query 3. ClientDataSet.ProviderName := DataSetProvider 4. ClientDataSet.IndexDefs[0] -> Fields := (nome do campo) GroupingLevel := 1 Name := Indice 5. ClientDataSet.IndexName := Indice 6. ClientDataSet.Aggregates[0] -> Expression := Count(codigo) GroupingLevel := 1 AggregateName := grupo IndexName := Indice Active := True 7. ClientDataSet.AggregateActive := True 8. CampoGrupo.OnGetText -> if gbFirst in ClientDataSet.GetGroupState(1) then Text := Sender.asString else Text := '' 9. ClientDataSet.Active := True;
// para criar campos de calculo aggregate
FieldsEditor: New Field FieldType := Aggregate, DataType := Aggregate FieldName := 'Total' Active := True ReadOnly := True Visible := True Expression := 'count(codigo)' GroupingLevel := 1 IndexName := 'Indice'
(voce pode usar este campo normalmente na grid ou edit - o campo não estará disponivel ao abrir a combo que contem os fields no objectinspector, basta digitar o nome) |