Click here to Skip to main content
15,917,702 members
Articles / Programming Languages / Javascript
Alternative
Tip/Trick

Checkbox List With Filtering jQuery Widget

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
6 Jun 2013CPOL 11.6K   2   2
This is an alternative for "Checkbox List With Filtering jQuery Widget"

Introduction

The following modifications are about making the widget work correctly in jQuery 10+ versions.  I found that in jQuery 10.10.1, the Check All functionality didn't work.

Using the code 

The only code modifications that I made were in the jquery.ui.checkList.js file, the only thing that I changed was: 

JavaScript
var chkAll = $('<input/>').attr('type','checkbox').addClass('chkAll').click(function(){
    var state = $(this).attr('checked');
    var setState = false;
				
    setState = (state==undefined) ? false : true;

    o.objTable.find('.chk:visible').attr('checked', setState);

    self._selChange();
});  

by this: 

JavaScript
var chkAll = $('<input/>').attr('type','checkbox').addClass('chkAll').click(function(){
				
    var state = $(this).prop('checked');
    o.objTable.find('.chk:visible').attr('checked', state);
    self._selChange();
				
});  

and now works!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Uruguay Uruguay
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionCheckbox List With Filtering jQuery Widget Pin
Evren Yortuçboylu6-Jun-13 6:32
Evren Yortuçboylu6-Jun-13 6:32 
AnswerRe: Checkbox List With Filtering jQuery Widget Pin
Member 1058395412-Feb-14 19:17
Member 1058395412-Feb-14 19:17 
Hi i am getting error .
.I want a list of user name that should come from a web service method that is GetUsers()
Here i am pasting my code
public static List<SelectUsers> GetUsers()
{
DataTable dtUsers = SLAFacadeBLL.GetGIMUsers(Constants.GIM_USER_ACTIONS.CANLOG);
var items = new List<SelectUsers>();

DataView dvUsers = dtUsers.DefaultView;
dvUsers.RowFilter = "RESPOND = True";

if (dvUsers.Count > 0)
{

DataTable dt = dvUsers.ToTable();
foreach (DataRow row in dt.Rows)
{
SelectUsers selectuser = new SelectUsers();
selectuser.value = row["Id"].ToString(); // row["column name in the datatable"].ToString();
selectuser.text = row["Name"].ToString(); // row["column name in the datatable"].ToString();
items.Add(selectuser);
}

}
return items;

}
And my jquery
<script type="text/javascript">
$(function () {
var items = [{ text: 'checkbox-1 caption', value: '1'}];
$.ajax({
type: 'POST',
contentType: 'application/json;',
data: items,
dataType: 'json',
async: true,
url: 'LogGeneralIncidentForm.aspx/GetUsers',
success: function (result) {
alert(result.d);
}
});
$('#myCheckList').checkList({
listItems: items,
onChange: selChange
});

function selChange() {
var selection = $('#myCheckList').checkList('getSelection');

$('#selectedItems').text(JSON.stringify(selection));
}
});
</script>

And SelectUsers.cs

public class SelectUsers
{
public string value { get; set; }
public string text { get; set; }
}


Can you help me in this matter?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.