MihaMarkic / BlazorDevExtreme

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

Get SetOptions to work #25

Open sven5 opened 5 years ago

sven5 commented 5 years ago

Hi,

1. it's necessary to call JSON.parse(value) for the SetOptions js functions - especially for setting the DataSource. Example:

function BlazorDevExtreme_DxDataGrid_SetOption (element, key, value) {
    const option = JSON.parse(value);
    DevExpress.ui.dxDataGrid.getInstance(element).option(key, option);
};

2. Setting the DataSource in Controls.cs needs a Json conversion. Example:

public static Task SetDataSource(ElementRef dxTarget, object value)
{
     string jsonValue = SimpleJson.SimpleJson.SerializeObject(value);
     return JSRuntime.Current.InvokeAsync<object>("BlazorDevExtreme_DxDataGrid_SetOption", dxTarget, "dataSource", jsonValue);
}

Otherwise there is a problem between camelCase / PascalCase.