utest test

utest test

  • NA
  • 17
  • 498

Unable to fetch the selected filtered records in kendo

Apr 17 2020 2:06 AM
Html
 
<div id="divType" class="fieldBlock">
<div id="ddlCompleted" style="margin-left: 0px; display: none;" class="fieldBlock float-left">
<input type="text" id="Addhdn" style="display: none;" value='' />
Below is my function which will add the selected values into the list
This function is working fine when I directly open the dropdown and select 'n' number of records. However, if I filter it by searching in the dropdown list of values and then I select a value, the previous selection is getting unchecked.
How can I make this function work for both cases where it is either filtered selection check or direct check?
<script>
function onSelect(e) {
debugger;
var checkBox = $(e.item).find('input:checkbox');
if (checkBox.data('isClicked') != true) {
checkBox.prop('checked', !checkBox.is(':checked'));
}
checkBox.data('isClicked', false);
var catTypes = $(".cbComp").filter(":checked");
var selectedIds = '';
var list = [];
for (var i = 0; i < catTypes.length; i++) {
list.push(catTypes[i].value);
}
if (list.length != 0) { selectedIds = list.join(","); }
debugger;
$('#Addhdn').val(selectedIds);
if ($('#selectType').val() == "1") {
debugger;
loadDropDown(baseURL + '/Controller/Method?TypeId=' + $('#Addhdn').val());
}
e.sender.popup._closing = true;
$('.k-animation-container').unbind("mouseleave").bind("mouseleave", function () {
var kendoDropdown = $("#ddlCompletedKD").data("kendoDropDownList");
kendoDropdown.popup._closing = false;
kendoDropdown.close();
});
}
function onCheck(e) {
debugger;
$(e.target).data('isClicked', true);
}
</script>
Kendo DropDown Binding-
@(Html.Kendo().DropDownList()
.Name("ddlCompletedKD").AutoBind(false)
.HtmlAttributes(new { style = "width: 228px!important;", id = "ddlCompletedKD" })
.Template("<input type='checkbox' name='cbActType' onClick='onCheck(event);' class='cbComp' value='#:data.TypeId#' />)
.Events(e => e.Select("onSelect"))
.DataTextField("TypeName")
.DataValueField("TypeId")
.Filter("contains")
.DataSource(source =>
{
source.Read(read => { read.Action("LoadDDL", "Home").Data("LoadTypeParams");
}).ServerFiltering(false);
})
.Events(e => e
.DataBound("ddlDataBound"))
)
What i tried-
I had applied filter("contains") but search works if i select second record my previous record gets unselected
 
 

Answers (1)