ScheduleEventSettings with DataSource and SfDataManager

Hi

I have a problem with SfDataManager,

My code look like this

private IEnumerable<GrafikForm> Events;

 <ScheduleEventSettings DataSource="@Events"  TValue="GrafikForm" EnableTooltip="@TooltipEnable" Query="@LocalizationQuery">

     <ChildContent>

         <SfDataManager AdaptorInstance="@typeof(GrafikAdaptor)" Adaptor="Adaptors.CustomAdaptor">

         </SfDataManager>

     </ChildContent>

</ ScheduleEvents >

        public void OnLocalizationChange(Syncfusion.Blazor.DropDowns.MultiSelectChangeEventArgs<int[]> args)

        {

            WhereFilter predicate;


            if (args.Value != null && args.Value.Length > 0)

            {

                var filters = args.Value.Select(id => new WhereFilter

                {

                    Field = "LocationId",

                    Operator = "equal",

                    value = id

                });


                // Łączymy filtry operatorem "lub" (Or).

                predicate = filters.Aggregate((filter1, filter2) => filter1.Or(filter2));

                this.LocalizationQuery = new Query().Where(predicate);

            }

            else

            {

                this.LocalizationQuery = new Query();


            }

        }

Problem is that :

  1. When i have DataSource SfDataManager dont use GrafikAdaptor methods
  2. When i dont have DataSource i cant filter events with LocationId

I need to use GrafikAdaptor methods and filter events with  LocationId

3 Replies 1 reply marked as answer

RR Ram Raju Elaiyaperumal Syncfusion Team February 27, 2024 04:00 PM UTC

Dear Customer,

Thank you for reaching out with your query. we understand you're trying to filter data in the SfDataManager using the LocationId.

 

To achieve this, you can pass the LocationId as an additional parameter,  using the 'AddParams' method of the Query property of the Schedule, This will allow you to retrieve the provided LocationId in the data manager and filter the events based on it.

 

Here's an example of how you can implement this:

@using Syncfusion.Blazor.Schedule

@using Syncfusion.Blazor.Data

@using syncfusion_blazor_app.Data

 

<SfSchedule @ref="AvailabilityScheduleRef" TValue="AppointmentData" Width="100%" Height="600px" @bind-SelectedDate="@SelectedDate">

    <ScheduleViews>

        <ScheduleView Option="View.Day"></ScheduleView>

        <ScheduleView Option="View.Week"></ScheduleView>

        <ScheduleView Option="View.WorkWeek"></ScheduleView>

        <ScheduleView Option="View.Month"></ScheduleView>

        <ScheduleView Option="View.Agenda"></ScheduleView>

    </ScheduleViews>

    <ScheduleEventSettings TValue="AppointmentData" Query="@QueryData">

        <SfDataManager AdaptorInstance="@typeof(AppointmentDataAdaptor)" Adaptor="Adaptors.CustomAdaptor">

        </SfDataManager>

    </ScheduleEventSettings>

</SfSchedule>

 

@code {

    SfSchedule<AppointmentData>? AvailabilityScheduleRef;

    DateTime SelectedDate { get; set; } = new DateTime(2022, 5, 17);

    public static string _locationId = "1";

    public Query QueryData = new Query().From("AppointmentDataDB-bc").AddParams("LocationId", _locationId);

}

In this code, the AddParams method is used to add the LocationId as a parameter to the query. This parameter can then be accessed in the data manager to filter the events.

For your convenience we have created a sample, Kindly check on the attached sample.

 

I hope this helps. If you have any further questions or need additional assistance, please don't hesitate to ask.

               

Regards,Ram


Attachment: BlazorSchedulerCRUDusingcustomadaptor_333bc264.zip


B“ Bartek “Egzennn” Wlodarczyk February 28, 2024 10:39 AM UTC

Hi,


I looked at your project, and even in it that doesnt work

Image_8816_1709116698375Image_4755_1709116746818

Image_2040_1709116746818


Regards



RR Ram Raju Elaiyaperumal Syncfusion Team March 1, 2024 04:37 PM UTC

Hi Bartek,

In the ReadAsync method, you can retrieve the query parameters. With these parameters, you can perform the filtering operation. In your case you can get the location Id 

In this code, You can retrieve the 
LocationId from the query parameters. Then, you can filter the EventData based on this LocationId.

Please refer to the attached image for reference.


We hope this helps. If you have any further questions or need additional assistance, please don't hesitate to ask.

Regards,

Ram


Marked as answer
Loader.
Up arrow icon