MihaMarkic / BlazorDevExtreme

Blazor interop for DevExtreme library
MIT License
30 stars 5 forks source link

BlazorDevExtreme_Component_Init not being called #20

Open sven5 opened 5 years ago

sven5 commented 5 years ago

Hi Miha,

I'm currently trying to attach to the event Datagrid.OnInitialized. Though I set OnInitializedEnabled to true the event is not being called. While searching through registration.js I found out that the function BlazorDevExtreme_Component_Init is not being called. Only BlazorDevExtreme_DxDataGrid_Init is called. But the event lives in BlazorDevExtreme_Component_Init Could you please look into it?

As a thank you, I will provide a new datagrid demo bound to Web API backend. :smile:

Regards Sven

sven5 commented 5 years ago

Update:

I want to attach the OnInitialized event of the datagrid to call some JS to be able to attach an Web API AspNet data store.

I was successful in adding some init code in the BlazorDevExtreme_DxDataGrid_Init Please see my workaround in Registration.js.

Now I'm able to attach to the ComponentInterop.Initialized event, see here:

 protected override void OnInit()
    {
        DevExpress.ComponentInterop.Initialized += OnInitialized;
        base.OnInit();
    }

    void OnInitialized(object sender, JQueryEventArgs e)
    {
        // it's impossible to add an id attribute to the Dxdatagrid component.
        if (e.Identifier?.StartsWith("DxDataGrid") == true)
        {
             […]
        }
    }

I think you should either call base widget functionality (Widget, Component, GridBase etc.) in any master widget component or implement some logic for inheritance.

sven5 commented 5 years ago

I attached to the onContentReadyevent to set the grid's datasource by JavaScript. the onInititalizedevent is not suitable because the grid is not ready yet.

Update: I have successfully bound the grid to a Web API backend with the help of DevExtreme AspNet library. All CRUD operations are working against my EF Core data layer.