Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7889213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:02:27+00:00 2026-06-03T06:02:27+00:00

I have an custom TDatasetProvider that allows to create new fields to whatever data

  • 0

I have an custom TDatasetProvider that allows to create new fields to whatever data it provides.

So, let’s say you got the folowing fields on the original dataset:

  • CustomerId
  • Name
  • Age

And you need to select it on DBGrid using showing an Bitmap. Well, you can since my DSP can add
an boolean field called Selected to the dataset data.

The way I do that now:

  1. Create 2 TClientDataset objects (Origin and Target)
  2. In Origin, I load the data got from the parameters of the InternalGetRecords method (I overrode it)
  3. In Target, I create the fielddefs defined from the Origin dataset and add the fielddefs created in design-time by the developer
  4. Execute an CreateDataset on Target
  5. And, row-by-row (and field-by-field), I copy the data from the Origin database to the Target dataset
  6. In the end, return the Data variant as a return value from InternalGetRecords.

I really don’t know if there’s a more elegant (and faster) way to do that. There’s another (faster and/or elegant) way to get that result?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:02:28+00:00Added an answer on June 3, 2026 at 6:02 am

    It seems that after loading the data from the source dataset, you can call IDSBase.AddField to add more fields:

    uses
      DB, DBCommon, DBClient, DSIntf;
    
    type
      THackClientDataSet = class(TClientDataSet);
    
    procedure EncodeFieldDesc(var FieldDesc: DSFLDDesc;
      const Name: string; DataType: TFieldType; Size, Precision: Integer;
      Calculated: Boolean; Attributes: TFieldAttributes);
    begin
      // ... copied from TClientDataSet.EncodeFieldDesc
    end;
    
    //...
    var
      FldDesc: DSFLDDesc;
    begin
      FillChar(FldDesc, SizeOf(FldDesc), 0);
      EncodeFieldDesc(FldDesc, 'SELECTED', ftBoolean, 0, 0, False, []);
      with THackClientDataSet(DataSet) do
        Check(DSBase.AddField(@FldDesc));
      // now you can create a second client dataset and assign it DataSet.Data directly:
      // DataSet2.Data := DataSet.Data;
      // DataSet2 now contains the new field (with empty values in all existing records)
    end;
    

    I didn’t test it thoroughly but the simple example above worked as expected, I was able to navigate the second client dataset and edit the values of all fields as usual.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have custom SPlist with some fields that I'd like to bind to a
I have custom classes that I currently instantiate within App.xaml as resources. I want
We have custom headers in the Silverlight DataGrid using the ContentTemplate. We've got a
I have custom event that has several different subscribers who will all use the
I have custom gallery. Gallery represents items that are frame layout. There are one
I have custom component that I can place in my layout file (XML) for
I have custom drupal module. I receive result from a webservice that I need
I have custom SiteMapProvider and RoleProvider that works together properly: IsAccessibleToUser returns false if
I have custom code inside of a SSRS report that needs to get the
I have custom exceptions in my django project that look like this: class CustomFooError(Exception):

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.