How to pass Params when using blazor grid SfDataManager UrlAdaptor with DataManagerRequest
I tried as per documentation on [FromBody] DataManagerRequest dm, string key = null, but dm.para. is null.
https://blazor.syncfusion.com/documentation/datagrid/data-binding/#change-query-parameter-value-dynamically
I am using the same code as following link
https://www.syncfusion.com/forums/155081/sfgrid-allowgrouping-on-urladaptor-getting-server-exception-404-not-found-blazor-18-1-56
SIGN IN To post a reply.
7 Replies
1 reply marked as answer
VN
Vignesh Natarajan
Syncfusion Team
June 22, 2020 06:16 AM UTC
Hi Ashimaz,
Thanks for contacting Syncfusion support.
Query: “How to pass Params when using blazor grid SfDataManager UrlAdaptor with DataManagerRequest”
We suggest you to achieve your requirement using AddParams method of Query property in Grid. Refer the below code example.
|
<SfGrid TValue="Orders" AllowFiltering="true" Query="@Qry" AllowGrouping="true" Toolbar="@(new List<string> {"Add","Edit","Delete","Update","Cancel" })" AllowSorting="true" AllowPaging="true">
. . .. ..
</SfGrid>
@code{
public Query Qry = new Query().AddParams("AddCode", 10);
public string[] GroupCols = new string[] { "CustomerID" };
|
Refer the below screenshot for your reference
|
|
Refer the below UG documentation for your reference
Kindly get back to us if you have further queries.
Regards,
Vignesh Natarajan
MT
MATIAS TOLEDO
October 20, 2021 02:47 PM UTC
Apparently you can't pass complex types. It worked with a string but not worked with an object. It is correct?
VN
Vignesh Natarajan
Syncfusion Team
October 21, 2021 01:26 PM UTC
Hi MATIAS,
Thanks for contacting Syncfusion support.
Query: “Apparently you can't pass complex types. It worked with a string but not worked with an object. It is correct?”
From your query, we suspect that you want to pass multiple arguments (a complex object) to sever side. We have provided support to pass multiple additional parameters to server, so we suggest you to achieve your requirement by using AddParams() method of Grid for each object like below.
Refer the below code example.
|
<SfGrid TValue="Orders" AllowFiltering="true" Query="@Qry" AllowGrouping="true" Toolbar="@(new List<string> {"Add","Edit","Delete","Update","Cancel" })" AllowSorting="true" AllowPaging="true">
<GridEvents TValue="Orders" OnActionFailure="@ActionFailure"></GridEvents>
<SfDataManager Url="/api/default" InsertUrl="/api/Default/Insert" UpdateUrl="/api/Default/Update" RemoveUrl="/api/Default/Delete" Adaptor="Adaptors.UrlAdaptor"></SfDataManager>
<GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true"></GridEditSettings>
<GridColumns>
<GridColumn Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field="CustomerID" HeaderText="Customer Name" Width="150"></GridColumn>
<GridColumn Field="OrderDate" HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
<GridColumn Field="Freight" HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
@code{
public Query Qry = new Query().AddParams("AddCode", 10).AddParams("AddComplex",15);
public string[] GroupCols = new string[] { "CustomerID" };
public void ActionFailure(FailureEventArgs Args)
{
}
}
|
Refer the below screenshot as output of above code example.
|
|
Please get back to us if you have further queries.
Regards,
Vignesh Natarajan
Marked as answer
Could you please kindly supply an example for this, because i am lost.
Thank you so much for your cooperate.
Best regards.
VN
Vignesh Natarajan
Syncfusion Team
November 4, 2021 04:38 AM UTC
Hi Tarik,
Greetings from Syncfusion support.
Query: “Could you please kindly supply an example for this, because i am lost.”
As per your request we have attached the sample to pass additional parameter to Url adaptor’s POST method (Grid DataManager). Refer the below sample for your reference
Please get back to us if you have further queries.
Regards,
Vignesh Natarajan
Thank you so much for the example it helps me allot.
VN
Vignesh Natarajan
Syncfusion Team
November 8, 2021 03:41 AM UTC
Hi Tarik,
Thanks for the update.
We are glad that our sample helps you to achieve your requirement.
Kindly get back to us if you have further queries.
Regards,
Vignesh Natarajan
SIGN IN To post a reply.
- 7 Replies
- 4 Participants
- Marked answer
-
AS ashimaz
- Jun 19, 2020 02:20 PM UTC
- Nov 8, 2021 03:41 AM UTC