Specify limits on data to pull from datasource.

9 posts, 0 answers
  1. Jason
    Jason avatar
    10 posts
    Member since:
    Dec 2016

    Posted 25 Jul Link to this post

    I am setting up a scheduler which will always be in Month view, and want to only pull data from my database for the displayed month, reading from the database when a new month is selected. I am anticipating sending my controller the selected date in my datasource.Read call, and when the arrows at the top are clicked to select a new month, another read is performed.

    How would I go about doing this?

  2. Petar
    Admin
    Petar avatar
    64 posts

    Posted 29 Jul Link to this post

    Hello Jason,

    Please check this "Filter Events on Server between Start and End of the Current View"demo project from our documentation. It demonstrates exactly what you want to be achieved. 

    If you have any questions regarding the implementation, please let me know. 

    Regards,
    Petar
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Jason
    Jason avatar
    10 posts
    Member since:
    Dec 2016

    Posted 29 Jul in reply to Petar Link to this post

    That looks good! I'll give it a try.

    Is there a way to use the HTML helper instead of javascript?

  4. Jason
    Jason avatar
    10 posts
    Member since:
    Dec 2016

    Posted 29 Jul in reply to Jason Link to this post

    I'm also using custom resources, as I need to color entries in the month view. I already have this working using the HTML helper.
  5. Jason
    Jason avatar
    10 posts
    Member since:
    Dec 2016

    Posted 29 Jul Link to this post

    So this is what I was able to get working, however as I mentioned above, I'd like to use the Razor HTML helper for consistancy.

    01.<div id="scheduler"></div>
    02. 
    03.<script>
    04.    $(function() {
    05.        $("#scheduler").kendoScheduler({
    06.            views: [
    07.                { type: "month", selected: true },
    08.            ],
    09.            resources: [{
    10.                dataSource: {
    11.                    transport: {
    12.                        read: {
    13.                            url: "@Url.Action("List", "Lab")"
    14.                        }
    15.                    },
    16.                    schema: {
    17.                        model: {
    18.                            id: "Id",
    19.                            fields: {
    20.                                Id: {
    21.                                    "type": "number"
    22.                                },
    23.                                Name: {
    24.                                    "type": "string"
    25.                                },
    26.                                Color: {
    27.                                    "type": "string"
    28.                                }
    29.                            }
    30.                        }
    31.                    }
    32.                },
    33.                title: "Lab",
    34.                field: "LabId",
    35.                dataTextField: "Name",
    36.                dataValueField: "Id",
    37.                dataColorField: "Color"
    38.            }],
    39.            dataSource: {
    40.                transport: {
    41.                    read: {
    42.                        url: "@Url.Action("List", "Calendar")",
    43.                        dataType: "json",
    44.                        contentType: "application/json; charset=utf-8",
    45.                        type: "POST"
    46.                    },
    47.                    parameterMap: function (options, operation) {
    48.                        if (operation === "read") {
    49.                            var scheduler = $("#scheduler").data("kendoScheduler");
    50.                            var result = {
    51.                                start: scheduler.view().startDate(),
    52.                                end: scheduler.view().endDate()
    53.                            }
    54.                            return kendo.stringify(result);
    55.                        }
    56.                        return kendo.stringify(options);
    57.                    }
    58.                },
    59.                serverFiltering: true,
    60.                schema: {
    61.                    model: {
    62.                        id: "taskID",
    63.                        fields: {
    64.                            taskID: { from: "TaskID", type: "number" },
    65.                            title: { from: "Title", defaultValue: "No title", validation: { required: true } },
    66.                            start: { type: "date", from: "Start" },
    67.                            end: { type: "date", from: "End" },
    68.                            startTimezone: { from: "StartTimezone" },
    69.                            endTimezone: { from: "EndTimezone" },
    70.                            description: { from: "Description" },
    71.                            recurrenceId: { from: "RecurrenceID" },
    72.                            recurrenceRule: { from: "RecurrenceRule" },
    73.                            recurrenceException: { from: "RecurrenceException" },
    74.                            ownerId: { from: "OwnerID", defaultValue: 1 },
    75.                            isAllDay: { type: "boolean", from: "IsAllDay" },
    76.                            LabId: { from: "LabId", type: "number" }
    77.                        }
    78.                    }
    79.                }
    80.            }
    81.        });
    82.    });
    83.</script>
  6. Petar
    Admin
    Petar avatar
    64 posts

    Posted 31 Jul Link to this post

    Hello Jason,

    We are currently working on your case but we will need more time to answer you. I will contact you back in the next 24 hours. 

    Regards,
    Petar
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  7. Petar
    Admin
    Petar avatar
    64 posts

    Posted 01 Aug Link to this post

    Hi Jason,

    Thank you for your patience. 

    Please accept my apologies for sending you the wrong project. The provided Scheduler component could be implemented with Razor HTML helper. Refer to the below-linked example that demonstrates the desired server filtering implementation using HTML helper:

    https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/scheduler/scheduler-server-filtering

    You could also find useful these Scheduler’s demos from our product page. 

    Please try implementing the Scheduler following the provided above information and let me know if have any questions or need further assistance. 

    Regards,
    Petar
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  8. Jason
    Jason avatar
    10 posts
    Member since:
    Dec 2016

    Posted 01 Aug in reply to Petar Link to this post

    Perfect, I will give that a try this week.
  9. Petar
    Admin
    Petar avatar
    64 posts

    Posted 05 Aug Link to this post

    Hi Jason,

    Take your time to test the proposed approach. Let me know if you need further assistance with the current issue. 

    Regards,
    Petar
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top