【问题标题】:How do I fetch data from Grid in Smartclient?如何在 Smartclient 中从 Grid 中获取数据?
【发布时间】:2014-05-22 09:16:16
【问题描述】:

如何从网格上的一行点击获取底层数据?

我的代码如下所示:

isc.ListGrid.create({
    ID: "countryList",
    width:1500, height:224, alternateRecordStyles:true,
    data: sampleData,
    fields:[
        {name:"id", title:"Id"},
        {name:"name", title:"Name"},
        {name:"version", title:"Version"},
        {name:"release", title:"Release"},
    ],

    canReorderFields: true,
    click: function (x) {
        alert('hi there' + x)
    }
})

如果我添加点击功能,会弹出警报。

如果放入一个参数“x”,那似乎有某种价值,但我无法破译它的意思。我真正想要的是作为 sampleData 传入的底层 JSON 数据(见下文)。

{
id:"10621",
name:"PimsPacket020",
version:"0.1",
release:"undefined",},
{
id:"10621",
name:"PimsPacket020",
version:"0.1",
release:"undefined",
}

【问题讨论】:

    标签: javascript smartclient


    【解决方案1】:

    我已经有一段时间没有使用 Smartclient,但是,我认为网格行的更好选择事件是:

    selectionChanged: "someFunction(this.getSelection())"
    

    this.getSelection() 函数将返回一个记录数组,即使是单个选择。

    有关更多信息,我建议同时使用 Smartclient 在线文档(Smartclient 9.1 Documentation)和功能浏览器(Smartclient Feature Explorer)。此代码适用于早期版本;至少从 8.x 开始。

    我希望这会有所帮助。

    【讨论】:

      【解决方案2】:

      如果您的列表包含复选框 (selectionAppearance: "checkbox"),您必须使用包含所有选定项目的 this.getSelection()。 或者你用记录参数创建一个函数:

      click: function (record) {
        isc.say ("ID:" + record.id + "Name:" + record.Name); 
      }
      

      【讨论】:

        【解决方案3】:

        使用此功能检索您的记录

        recordClick: function (viewer, record, recordNum, field, fieldNum, value, rawValue) {
        alert('hi there' + record.name);
        }
        

        更多信息,请参考 smartclient 文档 http://www.smartclient.com/docs/8.2/a/b/c/go.html#method..ListGrid.recordClick

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2020-03-06
          • 1970-01-01
          • 2020-05-31
          • 2021-02-10
          • 2022-07-24
          • 2018-12-27
          • 2020-02-24
          相关资源
          最近更新 更多