Hi,
I would like to use extended models in urlapadaptor.
It would be different structure in request and different in response than the data type of grid.
For example an edit action response:
{
"Data" : {<it is instance of the grid type>},
"Message" : "Custom message to show in page if not empty"
}
Show the "Message" and throw the Data object to the grid in one request-response process.
Is there any way to manipulate request and response objects in urladaptor?
Any event or something...
I tried to inherit the urladaptor and use it as customadaptor, but it causes type error in runtime. If I tried to use as urladaptor, than the original adaptor works, I think.
I tried to create custom adaptor from DataAdaptor, but it used a websocket. I want to use simple rest api requests.
I would like similar working as urladaptor, but custom requests and response handling.
Thanks for your help!
Best regards,
Otto
|
<SfGrid @ref="Grid" ID="GridOneTwo" TValue="EmployeeData" AllowPaging="true" AllowFiltering="true">
<SfDataManager @ref="DataManagerRef" Url="/api/Values" Adaptor="Adaptors.UrlAdaptor"></SfDataManager>
<GridColumns>
<GridColumn Field=@nameof(EmployeeData.Id) HeaderText="Id" IsPrimaryKey="true" IsIdentity="true" Visible="true" ShowInColumnChooser="false" />
. ..
</GridColumns>
</SfGrid>
@code{
SfGrid<EmployeeData> Grid;
public SfDataManager DataManagerRef { get; set; }
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
DataManagerRef.DataAdaptor = new TestOData(DataManagerRef);
}
base.OnAfterRender(firstRender);
}
public class TestOData : UrlAdaptor
{
public TestOData(DataManager dm) : base(dm)
{
}
public override object ProcessQuery(DataManagerRequest queries)
{
RequestOptions ActualReturnValue = (RequestOptions)(base.ProcessQuery(queries));
//you can customize the query here
Console.WriteLine(ActualReturnValue.Url);
Console.WriteLine(ActualReturnValue.BaseUrl);
return ActualReturnValue;
}
public override async Task<object> ProcessResponse<T>(object data, DataManagerRequest queries)
{
HttpResponseMessage response = data as HttpResponseMessage;
//you can customize the response here
var ActualReturnValue = await base.ProcessResponse<T>(data, queries);
return ActualReturnValue;
}
}
} |
Thanks for your help. I am looking for this solution.