1

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.

KreepN
  • 8,528
  • 1
  • 40
  • 58
splatto
  • 3,159
  • 6
  • 36
  • 69
  • 1
    Looking good since your last posts splatto. I'm curious as to if you have any code behind to handle the "checking" of the checkboxes when you go to edit/view the details of those appointments. If so, could you post it? – KreepN Sep 26 '11 at 19:33
  • Thanks boss. I have nothing handling it. It seems that the scheduler control is smart enough to figure that out, as per in Telerik's examples. In my implementation, it is able to figure out that first 'Legislator' check on its own. I hope that clarifies for you! – splatto Sep 27 '11 at 13:42
  • Just because I can't set any project up to work exactly like yours, is there an event of any sort that fires when you open up the "Edit Appointment" window? Also, which example are you referencing where you see it do what you are looking for? I have a few of them open and would like to compare. – KreepN Sep 27 '11 at 13:47
  • No event fires until the appointment has been edited. I was looking at this demo - http://demos.telerik.com/aspnet-ajax/scheduler/examples/advancedformtemplate/defaultcs.aspx Although now that I look closer, I see that there is a dropdown and on the MultipleValuesResourceControlCS.ascx.cs source, I can tha tit appears the checks are being set in a method called in the Page_Load() method. I'm guessing that by emulating and modifying that control I would also be able to implement a dropdownlist rather than a checkboxlist. Am I on the right track? – splatto Sep 27 '11 at 14:20
  • 1
    Telerik components are awesome. The scheduler is a piece of trash. I've spent many a night trying to get that convoluted junk to do something even remotely useful. Hate 2 say it but I ended up just rolling my own. – Maxim Gershkovich Sep 27 '11 at 15:24
  • Check the Edit in my answer for some possible clarification in regards to the methods they call and in what order. – KreepN Sep 27 '11 at 16:18

1 Answers1

1

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.

KreepN
  • 8,528
  • 1
  • 40
  • 58
  • I implemented the controls from the project you linked and my scheduler is now using that grid with the multiple values resource control (excluding the provider, I'm using the ResourceTypes field). But I can't for the life of me get the program to select more than one of the resources whose relationship are defined in the database. When I put a breakpoint and step through the MarkSelectedResources() method, the call to Appointment.Resources.GetResourcesByType(Type) only returns one of the resources. – splatto Sep 28 '11 at 18:09
  • When you step through the code and get to foreach (Resource res in resources), how many resources is your scheduler pulling. The example has 3 students and when it gets to the private IEnumerable GetResources(string resType) method, you can see it is pulling the correct amount and then proceeding to mark them in a different method. http://i.imgur.com/MqxMf.png – KreepN Sep 28 '11 at 18:31
  • I'm thinking I may know what the problem is, but it's frowned upon to chat in the comments. Think you could possibly join the Chat room called Telerik, located at the top of this site? I'm the only one in there and could probably help you out. – KreepN Sep 28 '11 at 19:06