【问题标题】:flex checkbox value not selected from database未从数据库中选择 flex 复选框值
【发布时间】:2011-02-22 07:08:58
【问题描述】:

我有一个小的 flex 数据网格。 dataProvider 是一个 xmlList。 我有两列,userList 和用户权限。用户权限列 作为复选框。复选框的值在 mySQL 中存储为 0 和 1。 从 PHP 返回时,我将它们转换为真或假。 它将值正确返回到前端。

但是在 itemrenderer 内部,复选框没有被设置为 true 或 false。 要么一切都是真的,要么一切都是假的。

这是我的代码。 http://www.freeimagehosting.net/uploads/4ba76933d3.gif

如何从数据库值中正确设置复选框的值?

请帮忙。

【问题讨论】:

    标签: apache-flex datagrid checkbox dataprovider


    【解决方案1】:

    改变

    <mx:CheckBox selected="{data.@selected}"/>

    <mx:CheckBox selected="{Boolean(Number(data.@selected))}"/>(更正为Amarghosh

    它应该可以正常工作。

    【讨论】:

    • 我肯定会使用selected="{Boolean(Number(data.@selected))}"{data.@selected == "1"}。字符串 "0"(与任何其他非空字符串一样)在 javascript 中计算为 true(当然在 actionscript 中也是如此)。
    • 我错过了他有 0, 1 作为可能性,我的解决方案是如果 PHP 返回真假字符串:)
    • 嘿,非常感谢 Ladislav 和 Amar。 selected="{Boolean(Number(data.@selected))}" 有效。
    • 同样,字符串 "false" 与任何其他非空字符串一样,计算结果为布尔值 true。试试这段代码,自己看看if("false") alert("true"); else alert("false");
    • 哦,该死的,用 Boolean('true') 测试它而不是用 Boolean('false')...只是表明你必须测试每个案例 :) 谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-22
    • 1970-01-01
    • 2020-03-31
    • 1970-01-01
    相关资源
    最近更新 更多