根据引用字段

时间:2017-12-22 07:30:11

标签: sapui5

List items with toolbar

嗨,专家,我正在尝试提出一个批准应用程序,但不是采用主从细节方法。如上所示,我希望它是一个带有2个选项卡的表格格式; 1个选项卡用于批准列表,另一个选项卡用于批准的项目。

例如,我有以下json数据,是否可以根据“状态”过滤模型,并将过滤后的结果动态绑定到1个表,但会根据单击的选项卡显示结果:对于Approval选项卡和Approved选项卡:

"QNPResult": [
        {
            "QNPNo": "QNP01",
            "MatDesc": "BROWN SUGAR",
            "PY": "38.46",
            "ACT": "35.17",
            "BP": "38.7",
            "OpenPOBal": "33.44",
            "CurrentPrice": "KG",
            "InvStock": "29.04",
            "InvMonth": "Feb 2018",
            "RecoVol": "700,000",
            "BookUntil": "Book until March 2018",
            "PriceOutlook": "Decreasing due to enough supply driven by crop season",
            "Status": "1"
        },
        {
            "QNPNo": "QNP02",
            "MatDesc": "WHITE SUGAR",
            "PY": "39.46",
            "ACT": "41.17",
            "BP": "48.7",
            "OpenPOBal": "43.44",
            "CurrentPrice": "KG",
            "InvStock": "49.04",
            "InvMonth": "March 2018",
            "RecoVol": "800,000",
            "BookUntil": "Book until March 2019",
            "PriceOutlook": "Decreasing due to enough supply driven by crop season",
            "Status": "1"
        },
        {
            "QNPNo": "QNP03",
            "MatDesc": "SUGAR",
            "PY": "69.46",
            "ACT": "71.17",
            "BP": "88.7",
            "OpenPOBal": "93.44",
            "CurrentPrice": "KG",
            "InvStock": "19.04",
            "InvMonth": "March 2019",
            "RecoVol": "100,000",
            "BookUntil": "Book until March 2020",
            "PriceOutlook": "Decreasing due to enough supply driven by crop season",
            "Status": "2"
        }
    ],

如果有更好的方法来实现我想要的设计,请告诉我。提前谢谢!

3 个答案:

答案 0 :(得分:2)

根据您链接的图片以及您描述的行为,我建议您使用SAPUI5 SDK中的此方法 - 演示工具包:Icon Tab Bar - Filter
看看Controller,handleIconTabBarSelect方法可以解决这个问题:根据选定的选项卡,它会使用不同的oBinding.filter(aFilters);个实例来过滤表的绑定sap/ui/model/Filter

答案 1 :(得分:1)

var status1 = [];
var status2 = [];
for(var i = 0; i<QNPResult.length; i++){
   if(QNPResult[i].Status === "1"){
      status1.push(QNPResult[i]);
   }else{
      status2.push(QNPResult[i])
   } 
}
  

将这些数组设置为从属表模型。

答案 2 :(得分:1)

有很多方法可以做到这一点。这是一个 http://jsbin.com/yavuhay/edit?js,output

function login($user,$pass)
{
    $this->db->where('device', $user);
    $this->db->where('password', $pass);
    $query = $this->db->get('devices');
    if($query->num_rows()==1) {
        return $query->row_array();
    } else {
        $this->session->set_flashdata('error', 'Username atau password salah!');
        redirect('login');
    }
}

function update($id,$stat)
{
    $data['status'] = $stat;
    $stat = 1;
    $this->db->where('kd_device', $id);
    $this->db->update('devices', $stat);
    return TRUE;
}