function removeHierarchyCell() {
var data = $('#GridName').data('kendoGrid').dataSource.data();
// Remove row expansion when no data
$.each(data, function (i, row) {
var hasChildren = row.get("ChildModel");
if (hasChildren === null || hasChildren === undefined || hasChildren.length == 0) {
$('tr[data-uid="' + row.uid + '" ] ').find(".k-hierarchy-cell a").remove();
}
});
}
Is there some way to keep these removed from the parent grid?
1 Answer, 1 is accepted
Hi, Jason,
Thank you for the provided code snippet.
The dataBound event is triggered any time you execute a Grid operation(filtering, sorting, paging, etc.). This means that the icon should also be removed when you're applying or removing filters.
Dojo example:
https://dojo.telerik.com/@gdenchev/onuXoguc
If the icon reappears after an operation, that means the following line is not getting reached:
$('tr[data-uid="' + row.uid + '" ] ').find(".k-hierarchy-cell a").remove();
Could you make sure that the code gets into the if condition and that the correct row is selected?
Additionally, if you could reproduce the problem in a Dojo(you can use the one from above as a starting point) and share it with me, I might be able to find what's causing the issue.
Let me know if you have any questions.
Best Regards,
Georgi Denchev
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
I will double check that line to make sure it is pulling an actual row. Also I should have mentioned this and thought I did, but I had the data for the detail gird being bound to data passed in from the parent grid model.
Could that be the cause of this behavior?
Hi, Jason,
Generally speaking that shouldn't be a problem. The issue occurs in the parent grid, so the data in the child shouldn't have any effect on it. The more likely cause is the conditional statement, however you'll need to double-check it to be certain.
Hi, Jason,
The DataBound event should be firing after each operation - read/filter/sort/page/group. DataBound isn't preventable so there should be nothing stopping it. My only guess would be that the event is attached to a different Grid from the one you're trying to debug.
Would it be possible for you to share a small dojo where the problem is reproduced, so I can run and examine it? This might give me an idea as to what may be causing the issue.
I'm only posting it here because I wasn't sure if there was a way to set this up in the dojo,
@(Html.Kendo().Grid<IndexViewModel>()
.Name("GroupGrid")
.Columns(columns =>
{
columns.Bound(model => model.PlacesOfService).Filterable(f => f.Cell(cell => cell.Operator("contains").ShowOperators(false)));
columns.Bound(model => model.GroupTypeName).Title("Group Insurance Type").Visible(@Model.IsParentGroup).Filterable(f => f.Cell(cell => cell.ShowOperators(false).Template("groupTypeFilter"))).Width(230);
columns.Bound(model => model.GroupNumbers).ClientTemplate("<p>#:GroupNumbers#</p>").Visible(@Model.IsParentGroup).Title("Associated Groups").Filterable(f => f.Cell(cell => cell.Operator("contains").ShowOperators(false)));
columns.Bound(model => model.PlanNumbers).ClientTemplate("<p>#:PlanNumbers#</p>").Visible(@Model.IsParentGroup).Title("Associated Plans").Filterable(f => f.Cell(cell => cell.Operator("contains").ShowOperators(false)));
columns.Bound(model => model.Drug).Filterable(f => f.Cell(cell => cell.Operator("contains").ShowOperators(false)));
columns.Bound(model => model.Requirements).Filterable(f => f.Cell(cell => cell.Operator("contains").ShowOperators(false)));
columns.Bound(model => model.BeginDate).ClientTemplate("#=BeginDateToLocal#").Filterable(f => f.Cell(cell => cell.ShowOperators(false)));
columns.Bound(model => model.EndDate).ClientTemplate("#=EndDateToLocal#").Filterable(f => f.Cell(cell => cell.ShowOperators(false)));
columns.Bound(model => model.Active);
columns.Bound(model => model.Id).Filterable(false).Sortable(false).Title("Actions").ClientTemplate("<a class=\"k-button k-button-icontext k-grid-edit\" href=\"" + Url.Action("Update", new { id = "#=Id#", groupId = configurationModel.GroupId, isParentGroup = configurationModel.IsParentGroup }) + "\"><span class=\"k-icon k-i-edit\"></span>Edit</a>"
+ "<input type=\"button\" class=\"k-button\" onclick=\"openCopyWindow('#=Id#');\"value=\"Copy\" />"
+ "<input type=\"button\" class=\"k-button\" onclick=\"groupIndexModel.toggleActive('#=Id#', '#=Active ? '" + Url.Action("Deactivate") + "' : '" + Url.Action("Activate") + "'#');\" value=\"#=Active ? 'Deactivate' : 'Activate'#\" />");
})
.ToolBar(toolbar =>
toolbar.Template(@<text>
<div class ="row">
<a id="AddNew" class="k-button k-button-icontext k-grid-add" href="@Url.Action("Create", new { groupId = configurationModel.GroupId, isParentGroup = configurationModel.IsParentGroup })"><span class="k-icon k-i-add"></span>Add new</a>
<div class="input-wrapper searchBar" style="width: 30%; display: inherit;">
@(Html.Kendo().TextBox().Name("groupSearch").HtmlAttributes(new { @class = "form-control border-style input-style", style = "border-radius: 6px;margin-left:75px;margin-top:2px;", @placeholder = "Search..." }))
<i class="k-icon k-i-search icon-style" style="margin-left: -20px; margin-top: 12px;"></i>
</div>
</div>
</text>))
.Sortable()
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
.Pageable()
.DataSource(builder => builder.Ajax().ServerOperation(false)
.Model(dataSource => dataSource.Id(viewModel => viewModel.Id))
.Filter(filter => filter.Add(p => p.Active).IsEqualTo(true))
.Filter(filter => filter.Add(p => p.EndDate).IsGreaterThanOrEqualTo(DateTime.Today))
.Sort(s => s.Add(p => p.EndDate).Descending())
.Read(read => read.Action<GroupController>(controller => controller.GroupRead(null, configurationModel.GroupId.Value, configurationModel.IsParentGroup)))))
Hi Jason,
Thank you for providing additional details.
However, I noticed that this account doesn't have any legitimate license assigned. Can you contact your Company License Representative and ensure that he/she assigns you a valid Telerik license? Feel free to contact Telerik Sales Department for any inquiries.
Then, we can proceed with resolving the technical question.
Hi Eyup,
I have my company's customer ID, will that suffice?
Hi Jason,
Thank you for getting back.
That's a nice beginning, but actually the assignment should be done by your Company. Try to contact the original Licence holder or representative and ask him/her to add you as a License Holder Dev Seat.