• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
Kevin的小家
混在代码世界的老菜鸟
博客园    首页    新随笔    联系   管理    订阅  订阅

JSON2Table实现

  1. 数据来源于网络

Power App 无法直接调用http访问网络,借助Automate实现,通过访问Automate流程,返回网络数据,在通过ParseJSON进行数据转换为JSON对象,通过Table函数之间转换为Table

  1. 定义Automate Flow

在Automate Flow 创建流程,流程名称为HttpGetData4Unhealthy,共三个节点,如下图所示。

    

 

 

  1. 在Power apps 使用Automate Flow

引入流程HttpGetData4Unhealthy

 

  1. Load数据

在Screen添加组件:

a. Text Label,Text 内容为 Json字符串

b.Text Input ,Mode,为Multiline,Default:varJSONStr

c.Button ,Text :load data

d. OnSelect写入代码如下:

//清除数据
Set(varJSONStr,Blank());
//运行Automate Flow 访问http,返回数据
Set(varJSONStr,
    HttpGetData4Unhealthy.Run().return);
//利用ParseJSON函数将json字符串转换为JSON对象
Set(varJSONObj,ParseJSON(varJSONStr));
//利用Table函数,将JSON对象的data属性转换为Table,此时可以在Gallery显示数据,但是显示的Text属性设置为 ThisItem.Value.rm_stk_index
Set(varTableObj,Table(varJSONObj.data));
//定义Collect 将Table的数据加载到Collect
ClearCollect(colTableRecords,
        ForAll(varTableObj,
        {
            assignee:Text(Value.assignee),
            assignee_email:Text(Value.assignee_email),
            rm_stk_index:Text(Value.rm_stk_index),
            category:Text(Value.category),
            legal_unit:Text(Value.legal_unit),
            channel_mrp:Text(Value.channel_mrp),
            stk_qty:Value(Value.stk_qty),
            stk_sc:Value(Value.stk_sc),
            stock_type:Text(Value.stock_type),
            task_type:Text(Value.task_type),
            unhealthy_qty:Value(Value.unhealthy_qty),
            unhealthy_sc:Value(Value.unhealthy_sc),
            version:Text(Value.version),
            wh_desc:Text(Value.wh_desc)
        }
​
));

  

  1. 显示在Galley上

在Screen上组件

a. Text Label,Text 内容为 查询

b.Text Input ,Name:txtSearch, Hint Text:查询

c. Gallery,添加显示组件Text Label ,Text属性设置为:ThisItem.rm_stk_index,属性名称参照OnSelect代码 定义Collect

e.在Gallery 的Items 写入如下代码:

Search(colTableRecords,
       txtSearch.Text,
       rm_stk_index,
       assignee,
       assignee_email)

  

  1. 界面效果如下:

     

  2. 运行效果

 

 
posted @ 2025-06-28 09:48  白米饭真好吃  阅读(15)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3