Custom Adaptor - Not Called

Hello,

  I have a blazor server side, with the following script

   <SfGrid @ref="grid" AllowPaging="true" TValue="Models.GroupModel" Query="@Query" Toolbar="@(new List<string>() { "Add"})">
            <Syncfusion.Blazor.Data.SfDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Syncfusion.Blazor.Adaptors.CustomAdaptor"></Syncfusion.Blazor.Data.SfDataManager>
            <Syncfusion.Blazor.Grids.GridPageSettings PageSize="3" PageSizes="true">

            </Syncfusion.Blazor.Grids.GridPageSettings>
            <GridEvents OnLoad="Load" OnActionBegin="ActionBeginHandler"
                        CommandClicked="OnCommandClicked"
                        TValue="Models.GroupModel"></GridEvents>
            <GridEditSettings AllowAdding="true" AllowEditing="false" AllowDeleting="false"></GridEditSettings>
            <GridColumns>
                <GridColumn Field=@nameof(Models.GroupModel.CODE) HeaderText="Code" TextAlign="TextAlign.Right" Width="88"></GridColumn>
                <GridColumn Field=@nameof(Models.GroupModel.DESCRIPTION) HeaderText="Description" Width="288"></GridColumn>
                <GridColumn Field=@nameof(Models.GroupModel.ACTIVE) HeaderText="Active" Type="ColumnType.Boolean" Width="120">
                    <Template>
                        @{
                            var _contact = (context as Models.GroupModel);
                            <div class="template_checkbox">
                                @if (_contact.ACTIVE == true)
                                {
                                    <input type="checkbox" checked disabled>
                                }
                                else
                                {
                                    <input type="checkbox" disabled>
                                }
                            </div>
                        }
                    </Template>

                </GridColumn>
                <GridColumn HeaderText="Manage Records" Width="150">
                    <GridCommandColumns>
                        <GridCommandColumn Type="CommandButtonType.Edit" ButtonOption="@(new CommandButtonOptions() { IconCss = "e-icons e-edit" })"></GridCommandColumn>
                        <GridCommandColumn Type="CommandButtonType.Delete" ButtonOption="@(new CommandButtonOptions() { IconCss = "e-icons e-delete"})"></GridCommandColumn>
                        <GridCommandColumn Type="CommandButtonType.None" ButtonOption="@(new CommandButtonOptions() { Content="..."})" Title="Details"></GridCommandColumn>
                        @*<GridCommandColumn Type="CommandButtonType.Save" ButtonOption="@(new CommandButtonOptions() { IconCss = "e-icons e-update", CssClass = "e-flat" })"></GridCommandColumn>
        <GridCommandColumn Type="CommandButtonType.Cancel" ButtonOption="@(new CommandButtonOptions() { IconCss = "e-icons e-cancel-icon", CssClass = "e-flat" })"></GridCommandColumn>*@
                    </GridCommandColumns>
                </GridColumn>
            </GridColumns>
        </SfGrid>

And this is the Adaptor code
  public class CustomAdaptor : DataAdaptor
        {
            [Inject] private Models.AIM_SMSContext _cont { get; set; }
            [Inject] ISessionStorageService session { get; set; }
            Guid? CUSTOMER_INDEXER = null;


            int iCount = 0;
            public CustomAdaptor()
            {

                _cont = new Models.AIM_SMSContext();
            }

            // Performs data Read operation
            public override object Read(DataManagerRequest dm, string key = null)
            {

                var CUST_INDEXER = dm.Params.Where(p => p.Key == "CUSTOMER_INDEXER").FirstOrDefault().Value;
                if (CUST_INDEXER != null)
                {
                    CUSTOMER_INDEXER = Guid.Parse(CUST_INDEXER.ToString());
                }

                IQueryable<Models.TblGroups> DataSource = _cont.TblGroups
                .Where(p => p.CustomerIndexer == CUSTOMER_INDEXER);

                List<Models.TblGroups> grps = new List<Models.TblGroups>() {
                     new Models.TblGroups(){ Active=true, Code="xxx", Description=sParams, Indexer=Guid.NewGuid() }
                };
                DataSource = grps.AsQueryable();

                if (dm.Search != null && dm.Search.Count > 0)
                {
                    // Searching
                    DataSource = DataOperations.PerformSearching(DataSource, dm.Search);
                }
                if (dm.Sorted != null && dm.Sorted.Count > 0)
                {
                    // Sorting
                    DataSource = DataOperations.PerformSorting(DataSource, dm.Sorted);
                }
                if (dm.Where != null && dm.Where.Count > 0)
                {
                    // Filtering
                    DataSource = DataOperations.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
                }
                int count = DataSource.Cast<Models.TblGroups>().Count();
                if (dm.Skip != 0)
                {
                    //Paging
                    DataSource = DataOperations.PerformSkip(DataSource, dm.Skip);
                }
                if (dm.Take != 0)
                {
                    DataSource = DataOperations.PerformTake(DataSource, dm.Take);
                }
                return dm.RequiresCounts ? new DataResult()
                {
                    Result = from p in DataSource
                             select new Models.GroupModel()
                             {
                                 ID = p.Indexer,
                                 ACTIVE = p.Active,
                                 DESCRIPTION = p.Description,
                                 CODE = p.Code
                             }
                    ,
                    Count = count
                } : (object)DataSource;
            }
        }

  In local run, this produces exact behaviour, but when I upload it online dataadaptor is not being called,

  For demo, please use http://main.adsinfo.biz, username:[email protected], pwd:Abc=123, It will display the strange behaviour that no data is being displayed.
  I will attached a sample image for my local run.


Attachment: Pictures_c9fe5bb.rar

15 Replies

RS Renjith Singh Rajendran Syncfusion Team January 15, 2021 11:00 AM UTC

Hi Martin, 

Greetings from Syncfusion support. 

We suggest you to try reproducing the reported problem after adding the AddScoped of CustomAdaptor class in Startup.cs file. 

[Startup.cs] 

public void ConfigureServices(IServiceCollection services){    ...    services.AddScoped<CustomAdaptor>();}

Kindly try the above suggestion and if you are still facing difficulties, then we suggest you to bind the “OnActionFailure” event to Grid. This event will be triggered for every failure in Grid. Please share the details you get in the “args” of this event handler for further analysis.  
 
And also kindly share with us the following details for better assistance. 

  1. Share the Syncfusion version details you are using.
  2. Share with us a simple issue reproducing sample for us to validate based on this scenario.
  3. Share with us the type(Server, Client or Hosted) of Blazor app you are using.

The provided information will help us analyze the problem, and provide you a solution as early as possible. 

Regards, 
Renjith Singh Rajendran 



MS Martin Sato January 16, 2021 04:14 AM UTC

Hi,

  I have tested it, the OnActionFailure is not triggered/called, please take note of the ff:
  
  
  1. Share the Syncfusion version details you are using. - Blazor 18.4.0.34
  2. Share with us a simple issue reproducing sample for us to validate based on this scenario. - I am attaching the project, please use the group link, I removed other pages for simplicity.
  3. Share with us the type(Server, Client or Hosted) of Blazor app you are using. I am using server side blazor.


Attachment: AIMS__DEMO_1716f452.rar


RS Renjith Singh Rajendran Syncfusion Team January 18, 2021 12:59 PM UTC

Hi Martin, 

Thanks for sharing the details. 

We are currently checking the shared details from our side. In the meantime, could you please add the Microsoft JSInterop in your hosted application’s OnActionFailure event handler, and check whether any error is thrown in browser console when data is not bind to Grid. If so, please share with us the exception details you get in browser console. This OnActionFailure event will be triggered each time when there is a failure encountered in Grid. 

 
public partial class Groups : ComponentBase 
{ 
    ... 
    [Inject] NavigationManager nav { getset; } 
    [Inject] public IJSRuntime jsRuntime { getset; } 
    private bool IsVisible { getset; } = false; 
    ... 
    SfGrid<Models.GroupModel> grid; 
 
    public void ActionFailureHandler(FailureEventArgs args) 
    { 
        jsRuntime.InvokeAsync<string>("console.log", args.Error.ToString()); 
    } 
    ... 
} 


The provided information will help us analyze the problem, and provide you a solution as early as possible. 

Regards, 
Renjith Singh Rajendran 



MS Martin Sato replied to Renjith Singh Rajendran January 20, 2021 07:39 AM UTC

Hi Martin, 

Thanks for sharing the details. 

We are currently checking the shared details from our side. In the meantime, could you please add the Microsoft JSInterop in your hosted application’s OnActionFailure event handler, and check whether any error is thrown in browser console when data is not bind to Grid. If so, please share with us the exception details you get in browser console. This OnActionFailure event will be triggered each time when there is a failure encountered in Grid. 

 
public partial class Groups : ComponentBase 
{ 
    ... 
    [Inject] NavigationManager nav { getset; } 
    [Inject] public IJSRuntime jsRuntime { getset; } 
    private bool IsVisible { getset; } = false; 
    ... 
    SfGrid<Models.GroupModel> grid; 
 
    public void ActionFailureHandler(FailureEventArgs args) 
    { 
        jsRuntime.InvokeAsync<string>("console.log", args.Error.ToString()); 
    } 
    ... 
} 


The provided information will help us analyze the problem, and provide you a solution as early as possible. 

Regards, 
Renjith Singh Rajendran 


Hi,

  This is the content of the browser log, as follows:

[2021-01-20T07:37:17.077Z] Information: Normalizing '_blazor' to 'http://main.adsinfo.biz/_blazor'.
blazor.server.js:1 [2021-01-20T07:37:17.793Z] Information: WebSocket connected to ws://main.adsinfo.biz/_blazor?id=0fwEDhenv9v-_XsiqX7aDQ.
_content/Syncfusion.Blazor/scripts/0.js:1 Uncaught SyntaxError: Unexpected token import
syncfusion-blazor.min.js:1 Uncaught (in promise) Error: Loading chunk 0 failed.
(missing: http://main.adsinfo.biz/_content/Syncfusion.Blazor/scripts/0.js)
    at Function.i.e (syncfusion-blazor.min.js:1)
    at syncfusion-blazor.min.js:1
    at c (syncfusion-blazor.min.js:1)
    at Generator._invoke (syncfusion-blazor.min.js:1)
    at Generator.next (syncfusion-blazor.min.js:1)
    at a (syncfusion-blazor.min.js:1)
    at s (syncfusion-blazor.min.js:1)
    at syncfusion-blazor.min.js:1
    at new Promise (<anonymous>)
    at syncfusion-blazor.min.js:1

Thanks.


MS Martin Sato replied to Martin Sato January 22, 2021 08:04 AM UTC

Hi Martin, 

Thanks for sharing the details. 

We are currently checking the shared details from our side. In the meantime, could you please add the Microsoft JSInterop in your hosted application’s OnActionFailure event handler, and check whether any error is thrown in browser console when data is not bind to Grid. If so, please share with us the exception details you get in browser console. This OnActionFailure event will be triggered each time when there is a failure encountered in Grid. 

 
public partial class Groups : ComponentBase 
{ 
    ... 
    [Inject] NavigationManager nav { getset; } 
    [Inject] public IJSRuntime jsRuntime { getset; } 
    private bool IsVisible { getset; } = false; 
    ... 
    SfGrid<Models.GroupModel> grid; 
 
    public void ActionFailureHandler(FailureEventArgs args) 
    { 
        jsRuntime.InvokeAsync<string>("console.log", args.Error.ToString()); 
    } 
    ... 
} 


The provided information will help us analyze the problem, and provide you a solution as early as possible. 

Regards, 
Renjith Singh Rajendran 


Hi,

  This is the content of the browser log, as follows:

[2021-01-20T07:37:17.077Z] Information: Normalizing '_blazor' to 'http://main.adsinfo.biz/_blazor'.
blazor.server.js:1 [2021-01-20T07:37:17.793Z] Information: WebSocket connected to ws://main.adsinfo.biz/_blazor?id=0fwEDhenv9v-_XsiqX7aDQ.
_content/Syncfusion.Blazor/scripts/0.js:1 Uncaught SyntaxError: Unexpected token import
syncfusion-blazor.min.js:1 Uncaught (in promise) Error: Loading chunk 0 failed.
(missing: http://main.adsinfo.biz/_content/Syncfusion.Blazor/scripts/0.js)
    at Function.i.e (syncfusion-blazor.min.js:1)
    at syncfusion-blazor.min.js:1
    at c (syncfusion-blazor.min.js:1)
    at Generator._invoke (syncfusion-blazor.min.js:1)
    at Generator.next (syncfusion-blazor.min.js:1)
    at a (syncfusion-blazor.min.js:1)
    at s (syncfusion-blazor.min.js:1)
    at syncfusion-blazor.min.js:1
    at new Promise (<anonymous>)
    at syncfusion-blazor.min.js:1

Thanks.

Hi,

   Any update on this?

Thanks.


RS Renjith Singh Rajendran Syncfusion Team January 25, 2021 10:42 AM UTC

Hi Martin, 

Thanks for sharing the details. 

We are currently checking this scenario from our side. We will update you further details in two business days. 

Until then we appreciate your patience. 

Regards, 
Renjith R 



RS Renjith Singh Rajendran Syncfusion Team January 27, 2021 01:26 PM UTC

Hi Martin, 

Thanks for your patience. 

We checked this case with your hosted link(http://main.adsinfo.biz/groups). We are facing an Sql network related problem, with the hosted link. And the Read method in Groups.razor.cs file triggers fine in the hosted link.  

Please refer the highlighted texts in below screenshot.  

 

We suspect that data is not bound to Grid because of this Sqldb connection problem. So please check this case from your side and get back to us if you need further assistance. 

Regards, 
Renjith R 



MS Martin Sato replied to Renjith Singh Rajendran January 28, 2021 02:43 AM UTC

Hi Martin, 

Thanks for your patience. 

We checked this case with your hosted link(http://main.adsinfo.biz/groups). We are facing an Sql network related problem, with the hosted link. And the Read method in Groups.razor.cs file triggers fine in the hosted link.  

Please refer the highlighted texts in below screenshot.  

 

We suspect that data is not bound to Grid because of this Sqldb connection problem. So please check this case from your side and get back to us if you need further assistance. 

Regards, 
Renjith R 


Hi,

    I double check and found no error, maybe during your testing, the server had some maintenance, anyways, please see attached picture. I am just wondering maybe cause I am injecting the context in the adaptor, but I still have to initialize it? since failure to initialize in the constructor, it becomes null meaning it is not injecting the correct object? 



Thanks.


RS Renjith Singh Rajendran Syncfusion Team January 28, 2021 12:53 PM UTC

Hi Martin, 

We are facing an exception when opening this site(http://main.adsinfo.biz/groups), but its hidden as the CircuitOptions.DetailedErrors is not enabled in the application.  

 

So, could you please enable CircuitOptions.DetailedErrors in your application and refresh the site and let us know to further validate this scenario from our side. 

[Startup.cs] 
 
public void ConfigureServices(IServiceCollection services) 
{ 
    services.AddRazorPages(); 
    services.AddServerSideBlazor().AddCircuitOptions(options => { options.DetailedErrors = true; }); 
    ... 
} 


Regards, 
Renjith R 



MS Martin Sato replied to Renjith Singh Rajendran January 29, 2021 01:30 AM UTC

Hi Martin, 

We are facing an exception when opening this site(http://main.adsinfo.biz/groups), but its hidden as the CircuitOptions.DetailedErrors is not enabled in the application.  

 

So, could you please enable CircuitOptions.DetailedErrors in your application and refresh the site and let us know to further validate this scenario from our side. 

[Startup.cs] 
 
public void ConfigureServices(IServiceCollection services) 
{ 
    services.AddRazorPages(); 
    services.AddServerSideBlazor().AddCircuitOptions(options => { options.DetailedErrors = true; }); 
    ... 
} 


Regards, 
Renjith R 


Hi,

  There must be something wrong with the adaptor, I queried the same table not from within the adaptor, data is returned successfully, the question now is why inside the adaptor it gets an error?

Please see below, I purposely displayed the groups data queried within the page to show you that the connection string has no issue only inside the adaptor, the connection string somehow got an issue.

Can you please tell me how to inject properly my context inside the adaptor w/o creating a new instance since I am forced to initialize due to null exception as follows:

Excerpt of my custom adaptor

 public class GroupCustomAdaptor : DataAdaptor
        {
            [Inject] private Models.AIM_SMSContext _cont { get; set; }

      Now supposedly that will give me access to my models, but w/o this
            public GroupCustomAdaptor()
            {

                _cont = new Models.AIM_SMSContext();
    I will get a null exception, so how to properly inject my db context inside the adaptor?

Thank you.




RS Renjith Singh Rajendran Syncfusion Team January 29, 2021 11:12 AM UTC

Hi Martin, 

Based on this scenario, we suggest you to use constructor injection instead of using [Inject]. Please use the below codes in your application. 

 
public class GroupCustomAdaptor : DataAdaptor 
{ 
    private Models.AIM_SMSContext _cont { getset; } 
    ...  
    public GroupCustomAdaptor(Models.AIM_SMSContext aIM_SMSContext) 
    { 
        _cont = aIM_SMSContext; 
    } 
    ... 


Please get back to us if you need further assistance. 

Regards, 
Renjith R


MS Martin Sato replied to Renjith Singh Rajendran February 1, 2021 04:27 AM UTC

Hi Martin, 

Based on this scenario, we suggest you to use constructor injection instead of using [Inject]. Please use the below codes in your application. 

 
public class GroupCustomAdaptor : DataAdaptor 
{ 
    private Models.AIM_SMSContext _cont { getset; } 
    ...  
    public GroupCustomAdaptor(Models.AIM_SMSContext aIM_SMSContext) 
    { 
        _cont = aIM_SMSContext; 
    } 
    ... 


Please get back to us if you need further assistance. 

Regards, 
Renjith R

I have an error after using a parameter, how to do it correctly?

Please see attached image.

Thanks.




RS Renjith Singh Rajendran Syncfusion Team February 1, 2021 11:26 AM UTC

Hi Martin, 

We suggest you to add the below highlighted line in Startup.cs file to overcome the reported problem. 

[Startup.cs] 
 
public void ConfigureServices(IServiceCollection services) 
{ 
    ... 
    services.AddScoped<GroupCustomAdaptor>(); 
} 


Please get back to us if you need further assistance. 

Regards, 
Renjith R 



MS Martin Sato replied to Renjith Singh Rajendran February 1, 2021 02:26 PM UTC

Hi Martin, 

We suggest you to add the below highlighted line in Startup.cs file to overcome the reported problem. 

[Startup.cs] 
 
public void ConfigureServices(IServiceCollection services) 
{ 
    ... 
    services.AddScoped<GroupCustomAdaptor>(); 
} 


Please get back to us if you need further assistance. 

Regards, 
Renjith R 


Thank you, it's working now.


RS Renjith Singh Rajendran Syncfusion Team February 2, 2021 07:51 AM UTC

Hi Martin, 

We are glad to hear that the provided suggestion helped you in achieving this requirement. 

Please get back to us if you need further assistance. 

Regards, 
Renjith R 




Loader.
Up arrow icon