Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Como fazer um refresh a um IWDBGrid
#1
Com a versão 14 do Intraweb, eu usava este procedimento para refrescar um IWDBGrid com Cell.Control para editar algumas colunas:
procedure RefreshIWGrid(zGrid: TIWDBGrid; Self: TIWAppForm);//2011-04-19 IW 11 version
var
  zPageContext: TIWBasePageContext;
  LControlRenderData: TIWHTMLTag;
  LControlContext: TIWCompContext;
  LContainerContext: TIWContainerContext;
begin
  zPageContext := Self.PageContext;
  LContainerContext := HTML40ContainerInterface(TIWDBGrid(zGrid)).ContainerContext;
  //2010-05-12 if you get A/v here, it is because renderinvisible controls on th eform is set to false!
  LControlContext := TIWCompContext.Create(zGrid, LContainerContext, zPageContext);
  //
  LControlRenderData := IIWHTML40Component(zGrid).RenderHTML(LControlContext);
  try
    LControlRenderData.AddParmsList(zGrid.ExtraTagParams);
    LControlContext.HTMLTag := LControlRenderData;
    zGrid.RefreshData(LControlContext, LControlRenderData);
  finally
    //if assigned(LControlRenderData) then//Don't free this, the controlcontext frees it
      //LControlRenderData.Free;
    if assigned(LControlContext) then//2011-01-25 Memory leak
      LControlContext.Free;
  end;

//  Self.AddToInitProc('FixDBGridHeaders(''' + zGrid.HTMLName + ''');');
end;


e funcionava lindamente.

Com a versão 15 do Intraweb estou a obter um AV na linha:
LControlRenderData := IIWHTML40Component(zGrid).RenderHTML(LControlContext);

e os dados não completamente refrescados. Já dei voltas e voltas e não consigo perceber porquê. O que mudou no Intraweb 15 para que isto tenha deixado de funcionar?

Obrigado
Reply
#2
Olá Cusco:
Code:
procedure RefreshIWGrid(zGrid: TIWDBGrid; Self: TIWAppForm);
begin
  zGrid.DoRefreshControl := True;
end;
Reply
#3
(10-11-2019, 05:41 PM)Jose Nilton Pace Wrote: Olá Cusco:
Code:
procedure RefreshIWGrid(zGrid: TIWDBGrid; Self: TIWAppForm);
begin
  zGrid.DoRefreshControl := True;
end;
Olá Jose, 
realmente seu código funciona mas algo falha no refresh no que diz respeito aos componentes que tenho em algumas células. 
Não estou a conseguir ter acesso aos conteúdos dos campos TIWEdit que estão numa determina coluna. 

Será que podia enviar-lhe um pequeno exemplo para ver do que falo? Obrigado.

Eu preciso passar o valor que recolho nos TIWEdit das colunas para o Intraweb para poder alterar a minha tabela.

(10-11-2019, 06:04 PM)Cusco69 Wrote:
(10-11-2019, 05:41 PM)Jose Nilton Pace Wrote: Olá Cusco:
Code:
procedure RefreshIWGrid(zGrid: TIWDBGrid; Self: TIWAppForm);
begin
  zGrid.DoRefreshControl := True;
end;
Vou colocar aqui o meu exemplo para ver se alguém pode me ajudar: 
O meu IWDBGrid.OnRenderCell é assim: 

procedure TIWForm1.IWDBGrid1RenderCell(ACell: TIWGridCell; const ARow, AColumn: Integer);
begin
  if ARow > 0 then
  begin
    case AColumn of
      2:
      if Not Assigned(ACell.Control) then
      begin
        ACell.Control := TIWEdit.Create(Self);
        with TIWEdit(ACell.Control) do
         begin
             Name := 'MyEdit1'; // Nome único para cada linha
            Tag := fdmemtable1.FieldByName('codigo').AsInteger;
            OnAsyncExit := AsyncExitEvent;
         end;
      end;
  end;
end; 

of meu AsyncExitEvent é assim: 
procedure TIWForm1.AsyncExitEvent(Sender: TObject; EventParams: TStringList);
var
  FieldQtName: String;
begin
  FieldQtName := EventParams.Values['IW_Action'];
  fdmemtable1.Locate('codigo', tiwedit(sender).tag);
  fdmemtable1.Edit;
  fdmemtable1.FieldByName('nome').AsString := EventParams.Values[FieldQtName];
  fdmemtable1.Post;

  IWDBGrid1.DoRefreshControl := True;
end; 

O que me está acontecendo é que não existe o parâmetro com o nome MyEdit1 em EventParams, ou seja, EventParams deveria ter estes 2 parâmetros:
IW_Action=MYEDIT1 
MYEDIT1=?????????????????????? // O texto que eu introduzi

No intraweb 14 isto funcionava bem. Como posso acessar o valor que introduzi?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)