在两个 Lightswitch 查询之间匹配项目

Match Items between two Lightswitch Queries

我在 HTML Lightswitch 客户端(当前版本)中有一个图块列表,我想为用户启用能够单击元素并显示该元素的 addEdit 屏幕的功能。

addEdit 屏幕使用查询 Complaints,图块列表使用查询 vw_Upcoming_Complaints。两个查询都有一个共同的唯一属性 Complant_ID

我目前有以下代码:

myapp.Main.vw_Upcoming_Complaints_Selected_execute = function (screen) {
    myapp.showAddEditComplaints(null, {
        beforeShown: function (addEditComplaintScreen) {
            addEditComplaintScreen.Complaint = screen.Upcoming_Complaints.selectedItem;
        },
        afterClosed: function (addEditScreen, navigationAction) {
            screen.selected_Complaint.details.refresh();
        }
    });
};

Lightswitch 目前在 addEdit 屏幕上显示正确的 Complaint_ID,但不会获取其余属性。

如何告诉 lightswitch 公共标识符是 complaint_Id 并且它应该在 Complaints 数据集中找到其余属性?

我无法编辑原始 Complaints 查询以包含 vw_Upcoming_Work 数据集的所有属性。

一种选择是按照以下几行更新您的 vw_Upcoming_Complaints_Selected_execute 函数:

myapp.Main.vw_Upcoming_Complaints_Selected_execute = function (screen) {
    myapp.showAddEditComplaint(null, {
        beforeShown: function (addEditComplaintScreen) {
            var id = screen.Upcoming_Complaints.selectedItem.Id;
            myapp.activeDataWorkspace.ApplicationData.Complaints_SingleOrDefault(id).execute().then(function onComplete(result) {
                if (result && result.results && result.results.length !== 0) {
                    addEditComplaintScreen.Complaint = result.results[0];
                }
            });
        },
        afterClosed: function (addEditScreen, navigationAction) {
            screen.selected_Complaint.details.refresh();
        }
    });
};

此更新假定您的数据源称为 ApplicationData,投诉 ID 是您的投诉查询的关键字。

基于这些假设,修订版通过对您的投诉查询使用 _SingleOrDefault 方法,简单地找到匹配的投诉实体,并将其分配给添加编辑屏幕。