Hello Team,
I am using Syncfusion.Blazor 19.1.0.57.
I have two problems one of which may be a bug.
1- I try to use SfDatePicker in a GridColumn/Template for a date field, when ever its value is changed and tried to save it sends null object to web api post or update methods.If no change is made in Date field then it saves without problem.
This can be a bug, can you please check if it works on 19.1.0.57 version for odata/web api crud?
2- I cannot make cascading dropdowns work for odata/web api and could not find an example for odata/web api cascading dropdowns fro blazor.
My razor component is like as follows:
<SfGrid @ref="Grid" TValue="Dealer">
<SfDataManager Url="odata/Dealers" Adaptor="Adaptors.ODataV4Adaptor" />
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" ShowDeleteConfirmDialog="true" Mode="EditMode.Dialog" />
<GridColumns>
...
</GridColumns>
<GridTemplates>
<DetailTemplate>
@{
Dealer dealer = context as Dealer;
DealerSetupLocation CurrentDealerSetupLocation = null;
string DistrictsUrl = null;
bool districtsIsEnabled = false;
}
<SfGrid @ref="DSLGrid" TValue="DealerSetupLocation" Query="@(new Query().Where("DealerId", "equal", dealer.CompanyId))">
<SfDataManager Url="odata/DealerSetupLocations" Adaptor="Adaptors.ODataV4Adaptor" />
<GridEvents TValue="DealerSetupLocation"
OnActionComplete=@((args) =>
{
CurrentDealerSetupLocation = args.Data;
if (args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Add))
{
CurrentDealerSetupLocation.DealerId = dealer.CompanyId;
}
DistrictsUrl = $"odata/Districts?$filter=ProvinceId eq {CurrentDealerSetupLocation?.ProvinceId}";
districtsIsEnabled = true;
})
OnActionBegin=@((args) =>
{
if (args.RequestType == Syncfusion.Blazor.Grids.Action.BeginEdit)
{
districtsIsEnabled = false;
}
}) />
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" ShowDeleteConfirmDialog="true" Mode="EditMode.Dialog" />
<GridColumns>
<GridColumn Field=@nameof(DealerSetupLocation.Id) IsPrimaryKey="true" Visible="false" ShowInColumnChooser="false" ShowColumnMenu="false" Width="0" />
<GridColumn Field=@nameof(DealerSetupLocation.ProvinceName)
[email protected] EditType="EditType.DropDownEdit" AutoFit="true">
<EditTemplate Context="DealerSetupLocation">
<SfDropDownList ID="ProvinceId" @
[email protected] TItem="Province" TValue="int" AllowFiltering="true" EnableVirtualization="true" FloatLabelType="FloatLabelType.Always"
[email protected]>
<SfDataManager Url="odata/Provinces" Adaptor="Adaptors.ODataV4Adaptor" />
<DropDownListFieldSettings Text="Name" Value="Id" />
<DropDownListEvents TItem="Province" TValue="int"
ValueChange=@((args) =>
{
CurrentDealerSetupLocation.District = null;
DistrictsUrl = $"odata/Districts?$filter=ProvinceId eq {args.Value};";
districtsIsEnabled = true;
DSLGrid.PreventRender(false);
}) />
</SfDropDownList>
</EditTemplate>
</GridColumn>
<GridColumn Field=@nameof(DealerSetupLocation.DistrictName)
[email protected] AutoFit="true">
<EditTemplate Context="DealerSetupLocation">
<SfDropDownList ID="DistrictId" @
[email protected] TItem="District" TValue="int?" FloatLabelType="FloatLabelType.Always"
[email protected] ShowClearButton="true" Enabled="@districtsIsEnabled">
<SfDataManager Url=@DistrictsUrl Adaptor="Adaptors.ODataV4Adaptor" />
<DropDownListFieldSettings Text="Name" Value="Id" />
</SfDropDownList>
</EditTemplate>
</GridColumn>
</GridColumns>
</SfGrid>
</DetailTemplate>
</GridTemplates>
</SfGrid>
@code{
protected SfGrid<Dealer> Grid { get; set; }
protected SfGrid<DealerSetupLocation> DSLGrid { get; set; }
}
Example Models:
public partial class Dealer
{
public Guid CompanyId { get; set; }
public virtual ICollection<DealerSetupLocation> DealerSetupLocations { get; set; }
}
public partial class DealerSetupLocation
{
public Guid Id { get; set; }
public Guid DealerId { get; set; }
public int ProvinceId { get; set; }
public int? DistrictId { get; set; }
public virtual Dealer Dealer { get; set; }
public virtual District District { get; set; }
public virtual Province Province { get; set; }
}
public partial class Province
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<DealerSetupLocation> DealerSetupLocations { get; set; }
public virtual ICollection<District> Districts { get; set; }
}
public partial class District
{
public int Id { get; set; }
public int ProvinceId { get; set; }
public string Name { get; set; }
public virtual Province Province { get; set; }
public virtual ICollection<DealerSetupLocation> DealerSetupLocations { get; set; }
public virtual ICollection<SubDistrict> SubDistricts { get; set; }
}
In above razor file
DSLGrid.PreventRender(false);
causes null reference exception and if i conet it then the second dropdown does not change Url.
Can you please direct me to an odata/web api cascading dropdown example if any? I could not find any.
Thanks.