Jump to content

TuniStringgrid - cannot update caption again after caption already set


rhennink

Recommended Posts

Hi,

 

I have something weird ;-)

 

When I do the init of a TUnistringGrid en add some column in the grid.

At this moment I fill the values of the columns with the start-values via grdData.Columns[iCol].Title.Caption  := 'startvalue xxxxx'

 

But when I put a button on the form, and try to update this column (again via grdData.Columns[iCol].Title.Caption := 'bbbbb';) the header is not updated.

when I debug i can see that the value is set correctly, but it is not visible on the screen.

 

Can i refresh this column (header) so the value is visible??

 

Richard

Link to comment
Share on other sites

Hi,

 

Can you try this approach for now ?!:

 

For example for the second column:

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniStringGrid1.JSInterface.JSCall('columnManager.getColumns()[1].setText', ['New title']);
end;

Best regards,

  • Upvote 1
Link to comment
Share on other sites

  • 1 month later...

Hi Delphi Developer,

 

  I am trying to setup some columns in a stringgrid dynamically.  The ColCount value I had setup at design time was 5.

  I tried to change the ColCount to 20 in code and then set the captions but get an Ajax Error:

 

    O13.columnManager.getColumns(...)[5] is undefined

 

 What I do notice when this error is display is that the grid only shows the 5 columns and not the 20.

  Here is some sample code that I have been testing with.

procedure TMainForm.UniButton2Click(Sender: TObject);
const
  TitleJS = 'columnManager.getColumns()[%d].setText';
  TitleJS2 = '''' + '%s' + '''';
var
  liX: Integer;
begin
  UniStringGrid1.ColCount := 20;

  for liX := 0 to 10 do
  begin
    UniStringGrid1.Columns.Add;
    UniStringGrid1.Columns[liX].Width := 60;
    UniStringGrid1.JSInterface.JSCall(format(TitleJS,[liX, TitleJS]), format(TitleJS2,['Hello There']));
  end;
end;

  

 

Link to comment
Share on other sites

Hi,

 

Thanks for the testcase

 

In this case just use like this:

  ...
  UniStringGrid1.ColCount := 20;

  for liX := 0 to 10 do
  begin
    UniStringGrid1.Columns.Add;
    UniStringGrid1.Columns[liX].Width := 60;
    //UniStringGrid1.JSInterface.JSCall(format(TitleJS,[liX, TitleJS]), format(TitleJS2,['Hello There']));
    UniStringGrid1.Columns[liX].Title.Caption := 'New Title'+IntToStr(liX); //<----------------
  end;
  ...

Best regards,

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...