Hi,
I'm looking for a way to programmatically set the treeview checkbox to an intermediate state and also change the color of the box.
Could you please help me?
Regards,
Sérgio Sant'Anna
|
<button @onclick="click">SetIntermediateState</button>
<SfTreeView @ref="treeview" CssClass="Tree" TValue="MusicAlbum" ShowCheckBox="true" AutoCheck="true">
<TreeViewFieldsSettings TValue="MusicAlbum" Id="Id" DataSource="@Albums" Text="Name" ParentID="ParentId" HasChildren="HasChild" Expanded="Expanded" IsChecked="IsChecked"></TreeViewFieldsSettings>
</SfTreeView>
...
public void click()
{
treeview.CheckAllAsync(new string[] { "3" });
} |
|
/*style to set the color of the checkbox*/
.Tree .e-checkbox-wrapper .e-frame {
background-color: #fff;
border-color: #e61809;
}
/*style to set the color of the intermediate state and checked state of checkbox*/
.Tree .e-checkbox-wrapper .e-frame.e-stop, .Tree .e-checkbox-wrapper .e-frame.e-check {
background-color: #e61809;
border-color: #e61809;
color: #fff;
} |
Hi Indumathy,
Thanks for the detailed explanation.
Sorry, but I forgot to mention that I need to do this without using the Autocheck feature.
In my solution I need to conditionally control the parent node selections. And that's why my need to programmatically check the intermediate state.
Could you please help me with this?
Regards,
Sérgio Sant'Anna
|
[Index.razor]
public async Task click()
{
string[] id = {"1","14" };
for (var i = 0; i < id.Length; i++)
{
await jsRuntime.InvokeAsync<object>("setstate", id[i]);
}
}
[_Host.cshtml]
function setstate(idValue) {
var tree = document.getElementsByClassName("e-treeview")[0];
//set intermediate state for the parent nodes.
tree.querySelector('[data-uid="' + idValue + '"]')
.querySelector(".e-frame.e-icons")
.classList.add("e-stop");
} |
Hi Indumathy,
This workaround solved my problem. Thanks!
Regards,
Sérgio Sant'Anna