惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
L
LangChain Blog
Blog — PlanetScale
Blog — PlanetScale
阮一峰的网络日志
阮一峰的网络日志
Microsoft Azure Blog
Microsoft Azure Blog
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog
Y
Y Combinator Blog
D
DataBreaches.Net
Engineering at Meta
Engineering at Meta
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements

博客园 - delphi中间件

array of TVarRec core.recordModel.pas 使用泛型序列结构体 DDD建模指导 rabbitMQ VS mqtt redis流的应用场景 redis消费者组 redis流的操作命令 领域服务与领域事件 业务规则和模型 限界上下文与统一语言 领域驱动 mqtt即时通讯 ActiveRecord ORM RAD(速成应用开发) unigui插件框架 工厂流水线式自动生产UNIGUI WEB软件 delphi cs\web一种统一的界面风格 - delphi中间件 - 博客园 动态生成unidbgrid 单据工厂 用json元数据填充模板 mormot2 ORM rest vs jsonrpc SSE技术详解:使用 HTTP 做服务端数据推送应用的技术 http持久连接 json-rpc 2.0 MCP服务器 RTTI对性能的影响 频繁地创建和销毁对象 TMultiPartFormData
unigui ajax交互
delphi中间件 · 2025-12-27 · via 博客园 - delphi中间件

unigui ajax交互

//'<button onclick="ajaxRequest(Menu.UnimList1, ''test'', [''param0=0'',''param1=1'']);">按钮</button>'
procedure TMenu.UnimFormCreate(Sender: TObject);
begin
  unimList1.Items.Add(
  '<h1>商品档案</h1>'
  +'<button onclick="ajaxRequest(Menu.UnimList1, ''spda'', [' + QuotedStr('class=TSpda') + ']);">打开</button>'
      );
end;

procedure TMenu.UnimList1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  try
    TUnimFormClass(FindClass(Params['class'].Value)).Create(UniApplication).Show;
  except
    on E: Exception do
      ShowMessage(className+'正在开发..');
  end;
end;
//'<button onclick="ajaxRequest(Menu.UnimList1, ''test'', [''param0=0'',''param1=1'']);">按钮</button>'
procedure TMenu.UnimFormCreate(Sender: TObject);
begin
    for var i: Integer := 0 to 4 do    begin
      unimList1.Items.Add(
      '<h1>'+i.ToString+'</h1>'
      +'<button onclick="ajaxRequest(Menu.UnimList1, ''test'', [' + QuotedStr('id='+i.ToString) + ']);">按钮</button>'
      );
    end;
end;

procedure TMenu.UnimList1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
if SameText('test', EventName) then
  ShowMessage(Params['id'].Value);
end;
procedure TMenu.UnimFormCreate(Sender: TObject);
begin
    for var i: Integer := 0 to 4 do    begin
      unimList1.Items.Add(
'<h1>'+i.ToString+'</h1>'
+' <button onclick="abtnclick('''+i.ToString+''')">按钮</button>'
+   ' </div>  '
      );
    end;
(* 按钮点击事件JS处理代码
创建aaa.js文件,内容如下:
function abtnclick(id){
  ajaxRequest(Menu.UnimList1, 'test',['id=' + id]);
}
ServerModule.CustomFiles 添加一行:
files\aaa.js
*)

end;

procedure TMenu.UnimList1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
if EventName ='test' then
UnimList1.Items[strtoint(Params.Values['id'])]:=
'  <h1>'+Params.Values['id']+' 已处理</h1>'
+' <button disabled  onclick="abtnclick('''+Params.Values['id']+''')">按钮</button>'
+   ' </div>  '
  ;
end;