资源未被“选择”;在 Telerik Scheduler 编辑对话框中

发布于 2024-12-06 08:22:27 字数 2412 浏览 0 评论 0原文

我已经在时间线视图上实现了 Telerik 调度程序。我允许我的 y 轴资源(倡导者)和会议之间存在 M:M 关系。我的调度程序如下所示:

Timeline View

当我双击会议的一个实例时,高级编辑对话框出现。但是,在这里,没有任何倡导者被选为会议参与者:

倡导者资源 - 编辑会议对话框

有一个时间线中出现本次会议的倡导者人数。为什么它们没有在编辑表单中显示为选中状态?

问题还不止于此。我有第二种类型的资源(立法者),它也与会议具有 M:M 关系。这里有一个类似的问题 - 我为这次会议和 4 位立法者定义了关系,但只检查了第一位立法者(其他三个保持未检查):

立法者资源 - 编辑会议对话框

我需要添加两种其他类型的资源(同样,每种资源都是 M:M 与会议),并且我预计我会遇到与我的两个资源类似的问题有已经添加了。

我已经能够通过更改调度程序的分组并通过 SQL 查询来直观地验证数据库中的关系是否有效。那么,为什么我看不到这些相关资源的检查情况呢?我的调度程序代码如下:

<telerik:RadScheduler runat="server" ID="RadScheduler1" 
    AdvancedForm-Enabled="true"
    AllowEdit="true" 
    AllowInsert="true" 
    DataEndField="End"
    DataKeyField="ID" 
    DataSourceID="EventsDataSource" 
    DataStartField="Start"
    DataSubjectField="Subject" 
    DayEndTime="17:00:00" 
    DayStartTime="07:00:00" 
    EnableAdvancedForm="true"
    Localization-HeaderMultiDay="Work Week" 
    OverflowBehavior="Expand" 
    OnAppointmentDelete="OnAppointmentDelete"
    OnAppointmentInsert="OnAppointmentInsert" 
    OnAppointmentUpdate="OnAppointmentEdited"
    OnNavigationComplete="RadScheduler1_NavigationComplete"
    SelectedDate="9/20/2011" 
    SelectedView="TimelineView" 
    >
        <AppointmentContextMenuSettings EnableDefault="true" />     
    <AdvancedForm Modal="true" />
    <ResourceTypes>
        <telerik:ResourceType KeyField="Adv_AdvocateID" AllowMultipleValues="true" Name="Advocate" TextField="Adv_FullName" ForeignKeyField="Adv_AdvocateID"
            DataSourceID="AdvocatesDataSource" />
    </ResourceTypes>
    <ResourceTypes>
        <telerik:ResourceType KeyField="Leg_LegID" Name="Legislator" AllowMultipleValues="true" TextField="Leg_FullName" ForeignKeyField="Leg_LegID"
            DataSourceID="LegislatorsDataSource" />
    </ResourceTypes>
    <TimelineView UserSelectable="true" GroupBy="Advocate" GroupingDirection="Vertical" />
    <MultiDayView UserSelectable="false" />
    <DayView UserSelectable="false" />
    <WeekView UserSelectable="false" />
    <MonthView UserSelectable="false" />
</telerik:RadScheduler>

我希望有人能够深入了解如何在编辑约会对话框中正确显示所选资源,我提前感谢您的帮助。

I've implemented Telerik scheduler on timeline view. I am allowing a M:M relationship between my y-axis resource (advocates) and Meetings. Here is what my scheduler looks like:

Timeline View

When I double click one of the instances of the meeting, the advanced edit dialog appears. However, in here, none of the advocates are selected as participants in the meeting:

Advocate Resources - edit meeting dialog

There are a number of advocates for whom this meeting appears in the timeline. Why do they not get displayed as selected in the edit form?

The problem doesn't end there. I have a second type of resources (legislators) that also has a M:M relationship with Meetings. There is a similar problem here - I have relationships defined for this meeting and 4 legislators, but only the first legislator is checked (and the other three remain unckecked):

Legislator Resources - edit meeting dialog

I need to add two other types of resources (again, each will be M:M with Meetings), and I expect that I will have a similar problem to the two I have already added.

I have been able to verify visually by changing the grouping of my scheduler and through SQL queries that the relationships in the database are valid. So, why am I unable to see each of these related resources checked? My scheduler code is as follows:

<telerik:RadScheduler runat="server" ID="RadScheduler1" 
    AdvancedForm-Enabled="true"
    AllowEdit="true" 
    AllowInsert="true" 
    DataEndField="End"
    DataKeyField="ID" 
    DataSourceID="EventsDataSource" 
    DataStartField="Start"
    DataSubjectField="Subject" 
    DayEndTime="17:00:00" 
    DayStartTime="07:00:00" 
    EnableAdvancedForm="true"
    Localization-HeaderMultiDay="Work Week" 
    OverflowBehavior="Expand" 
    OnAppointmentDelete="OnAppointmentDelete"
    OnAppointmentInsert="OnAppointmentInsert" 
    OnAppointmentUpdate="OnAppointmentEdited"
    OnNavigationComplete="RadScheduler1_NavigationComplete"
    SelectedDate="9/20/2011" 
    SelectedView="TimelineView" 
    >
        <AppointmentContextMenuSettings EnableDefault="true" />     
    <AdvancedForm Modal="true" />
    <ResourceTypes>
        <telerik:ResourceType KeyField="Adv_AdvocateID" AllowMultipleValues="true" Name="Advocate" TextField="Adv_FullName" ForeignKeyField="Adv_AdvocateID"
            DataSourceID="AdvocatesDataSource" />
    </ResourceTypes>
    <ResourceTypes>
        <telerik:ResourceType KeyField="Leg_LegID" Name="Legislator" AllowMultipleValues="true" TextField="Leg_FullName" ForeignKeyField="Leg_LegID"
            DataSourceID="LegislatorsDataSource" />
    </ResourceTypes>
    <TimelineView UserSelectable="true" GroupBy="Advocate" GroupingDirection="Vertical" />
    <MultiDayView UserSelectable="false" />
    <DayView UserSelectable="false" />
    <WeekView UserSelectable="false" />
    <MonthView UserSelectable="false" />
</telerik:RadScheduler>

I'm hoping someone can shed some insight into how to correctly display the selected resources in the edit appointment dialog, and I thank you in advance for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一人独醉 2024-12-13 08:22:27

我早些时候看过你刚刚找到的那个表格,这就是促使我问这个问题的原因。下面的方法似乎是我最关注的方法,因为它们似乎负责复选框的填充和每个条目的检查。

问题是,您现在拥有的很好,您只需将复选框控件替换到代码中,而不是像他们那样创建一个。

编辑:我浏览了 编程来查看按顺序调用的内容,以便您可以相应地调整它们以适合您的数据。

protected void Page_Load(object sender, EventArgs e)
{
    SemanticCheckBoxList resourceValue = new SemanticCheckBoxList();
    resourceValue.ID = "ResourceValue";
    ResourceValuesPlaceHolder.Controls.Add(resourceValue);

    if (resourceValue.Items.Count == 0)
    {
        PopulateResources();
        MarkSelectedResources();
    }
}


private void PopulateResources()
{
    foreach (Resource res in GetResources(Type))
    {
        ResourceValue.Items.Add(new ListItem(res.Text, SerializeResourceKey(res.Key)));
    }
}

private IEnumerable<Resource> GetResources(string resType)
{
    List<Resource> availableResources = new List<Resource>();
    IEnumerable<Resource> resources = Owner.Resources.GetResourcesByType(resType);

    foreach (Resource res in resources)
    {
        if (IncludeResource(res))
        {
            availableResources.Add(res);
        }
    }

    return availableResources;
}

private bool IncludeResource(Resource res)
{
    return res.Available || ResourceIsInUse(res);
}

private string SerializeResourceKey(object key)
{
    LosFormatter output = new LosFormatter();
    StringWriter writer = new StringWriter();
    output.Serialize(writer, key);
    return writer.ToString();
}

private void MarkSelectedResources()
{
    foreach (Resource res in Appointment.Resources.GetResourcesByType(Type))
    {
        ResourceValue.Items.FindByValue(SerializeResourceKey(res.Key)).Selected = true;
    }
}

我认为通过页面加载的代码不会在您的代码中使用,您只需要调用条件 if 语句内的方法即可。

I was looking at that form earlier, the one you just found, which is what prompted me to ask. The methods below seem to be the ones I'm focusing on the most as it would seem they are responsible for the population of the check box and the checking of each entry.

The thing is, what you have now is good, you would just have to substitute your checkbox control into the code rather than create one like they do.

EDIT: I went through the Program to see what gets called in order, so that you may adjust them accordingly to fit your data.

protected void Page_Load(object sender, EventArgs e)
{
    SemanticCheckBoxList resourceValue = new SemanticCheckBoxList();
    resourceValue.ID = "ResourceValue";
    ResourceValuesPlaceHolder.Controls.Add(resourceValue);

    if (resourceValue.Items.Count == 0)
    {
        PopulateResources();
        MarkSelectedResources();
    }
}


private void PopulateResources()
{
    foreach (Resource res in GetResources(Type))
    {
        ResourceValue.Items.Add(new ListItem(res.Text, SerializeResourceKey(res.Key)));
    }
}

private IEnumerable<Resource> GetResources(string resType)
{
    List<Resource> availableResources = new List<Resource>();
    IEnumerable<Resource> resources = Owner.Resources.GetResourcesByType(resType);

    foreach (Resource res in resources)
    {
        if (IncludeResource(res))
        {
            availableResources.Add(res);
        }
    }

    return availableResources;
}

private bool IncludeResource(Resource res)
{
    return res.Available || ResourceIsInUse(res);
}

private string SerializeResourceKey(object key)
{
    LosFormatter output = new LosFormatter();
    StringWriter writer = new StringWriter();
    output.Serialize(writer, key);
    return writer.ToString();
}

private void MarkSelectedResources()
{
    foreach (Resource res in Appointment.Resources.GetResourcesByType(Type))
    {
        ResourceValue.Items.FindByValue(SerializeResourceKey(res.Key)).Selected = true;
    }
}

I'd think the code via the page load wouldn't be used in yours, you would just need to call the methods inside the conditional if statement.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文