We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Listbox with checkbox select event

Thread ID:

Created:

Updated:

Platform:

Replies:

127211 Nov 2,2016 06:02 PM Nov 3,2016 02:49 AM ASP.NET MVC 1
loading
Tags: ListBox
Bernard Jurlina
Asked On November 2, 2016 06:02 PM

I'm trying to exec javascript function on list item checked/unchecked.
I have listbox in my view:

@Html.EJ().ListBox("lstCam").Height("200").Datasource((IEnumerable<CaptureSources>)ViewBag.dsCam).ListBoxFields(df => df.Text("name")).ShowCheckbox(true).ClientSideEvents(e => e.Select("onSelect"))

The function is like this:

<script type="text/javascript">
    function onSelect(args) {
        var target;
        target = $('#lstCam').data("ejListBox");
        var checkedItems = target.getCheckedItems();
        var sel;
        if (checkedItems.length) {
            $(checkedItems).each(function (index, ele) {
                sel += ele.value + ",";
            });
            
        }
    }
</script>

When I run the project, checkboxes in the listbox is looking like filled boxes, instead of checkmarks in empty box. This is something wrong?
And my other problem is when I select one item, the js function is not called.

Maybe a little help?
Thanks!


Prasanth Palani [Syncfusion]
Replied On November 3, 2016 02:49 AM

Hi Bernard,   
   
Thanks for contacting Syncfusion Support.   
   
 Query: when I select one item, the JS function is not called.    
   
If we enable the checkbox, only the checkChange event will be triggered instead of select/change event in the ListBox control. The select and change events are triggered only when the ListBox is rendered without the checkbox.      
   
Query: When I run the project, checkboxes in the listbox is looking like filled boxes, instead of checkmarks in empty box?      
   
We were unable to reproduce the above issue. When we ran the project, checkmarks in the checkboxes rendered properly in the ListBox control. Please ensure that you have referred dependent scripts and CSS files in your application. For you reference, we have prepared a simple ListBox MVC application with checkbox enabled. You can get that sample from:   
 
Sample location: Sample   
   
If the problem persists still, please modify the provided sample based on your application along with the replication procedure to showcase the issue. Or, you can share the code sample of how you had created the ListBox with checkbox and share the console errors, if any. This would help us to provide an appropriate solution at the earliest. 
 
Regards, 
Prasanth P 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;