Hi
I have a radlistbox item with check boxes. User can successfully Check and unchecked the items . Can i check if user click on the Item text, Unchecked if User again click on the Item text. Please provide your valuable Suggestion. ASAP
I have a radlistbox item with check boxes. User can successfully Check and unchecked the items . Can i check if user click on the Item text, Unchecked if User again click on the Item text. Please provide your valuable Suggestion. ASAP
8 Answers, 1 is accepted
0
Accepted
Princy
Top achievements
Rank 2
answered on 04 Feb 2013, 09:58 AM
Hi Prasad,
I was able to do your requirement on double click.Try the following code snippet and let me know your concern
aspx:
JS:
Thanks
Princy.
I was able to do your requirement on double click.Try the following code snippet and let me know your concern
aspx:
<
telerik:RadListBox
ID
=
"RadListBox1"
runat
=
"server"
CheckBoxes
=
"true"
OnClientItemDoubleClicking
=
"OnClientItemDoubleClicking"
<Items>
.................................
</
Items
>
</
telerik:RadListBox
>
<script type=
"text/javascript"
>
function
OnClientItemDoubleClicking(sender, args)
{
if
(args.get_item().get_checked() ==
false
)
{
args.get_item().set_checked(args.get_item().get_selected());
}
else
{
args.get_item().set_checked(
false
);
}
}
</script>
Thanks
Princy.
0
Sean O'Brien
Top achievements
Rank 1
answered on 01 Mar 2013, 11:24 AM
Prasad,
I achieved the functionality on single click using the OnClientSelectedIndexChanging event. Otherwise basically the same as the above recommendation. You might want to disable selecting so that it fires each time: args.set_cancel(true);
Also, in the first set_checked(...); call in Princy's version I'd just pass true.
Peace.
I achieved the functionality on single click using the OnClientSelectedIndexChanging event. Otherwise basically the same as the above recommendation. You might want to disable selecting so that it fires each time: args.set_cancel(true);
Also, in the first set_checked(...); call in Princy's version I'd just pass true.
Peace.
0
Sean O'Brien
Top achievements
Rank 1
answered on 01 Mar 2013, 11:44 AM
P.S. Basically, something like this:
function OnClientItemSelectedIndexChanging(sender, args) {
if (args.get_item().get_checked() == false) {
args.get_item().set_checked(true);
}
else {
args.get_item().set_checked(false);
}
args.set_cancel(true);
}
function OnClientItemSelectedIndexChanging(sender, args) {
if (args.get_item().get_checked() == false) {
args.get_item().set_checked(true);
}
else {
args.get_item().set_checked(false);
}
args.set_cancel(true);
}
0
John
Top achievements
Rank 1
answered on 18 Oct 2013, 05:52 AM
Hi,
I have a similar problem but I want the checkbox to be checked when the user clicks on an items text, index change doesn't work for me if you re-click on an item you've reindexed too.
i.e.
click on item, change index sets checkbox,
reclick on same item, change index doesn't fire as the index hasn't changed.
my requirements
click on item, set/unset checkbox depending on current value
click on item again to set, set/unset checkbox depending on current value
any help would be great as i can't seem to find a solution to allow me to do this and the onclientonclicked isn't available
thanks,
JC
I have a similar problem but I want the checkbox to be checked when the user clicks on an items text, index change doesn't work for me if you re-click on an item you've reindexed too.
i.e.
click on item, change index sets checkbox,
reclick on same item, change index doesn't fire as the index hasn't changed.
my requirements
click on item, set/unset checkbox depending on current value
click on item again to set, set/unset checkbox depending on current value
any help would be great as i can't seem to find a solution to allow me to do this and the onclientonclicked isn't available
thanks,
JC
0
Princy
Top achievements
Rank 2
answered on 18 Oct 2013, 07:52 AM
Hi John,
The following code snippet works fine at my end. But please note that it will change the default behaviour of the CheckBox. So you should write CheckBox checked logic inside 'OnClientItemChecked'.
ASPX:
C#:
JavaScript:
Thanks,
Princy.
The following code snippet works fine at my end. But please note that it will change the default behaviour of the CheckBox. So you should write CheckBox checked logic inside 'OnClientItemChecked'.
ASPX:
<
telerik:RadListBox
ID
=
"RadListBox1"
runat
=
"server"
CheckBoxes
=
"true"
AutoPostBack
=
"true"
OnPreRender
=
"RadListBox1_PreRender"
>
<
Items
>
<
telerik:RadListBoxItem
Text
=
"Item1"
runat
=
"server"
Value
=
"1"
/>
<
telerik:RadListBoxItem
Text
=
"Item2"
runat
=
"server"
Value
=
"2"
/>
<
telerik:RadListBoxItem
Text
=
"Item3"
runat
=
"server"
Value
=
"3"
/>
</
Items
>
</
telerik:RadListBox
>
C#:
protected
void
RadListBox1_PreRender(
object
sender, EventArgs e)
{
foreach
(RadListBoxItem item
in
RadListBox1.Items)
{
item.Attributes.Add(
"onclick"
,
"CellClick('"
+ item.Text +
"','"
+ item.Value +
"');"
);
}
}
JavaScript:
<script type=
"text/javascript"
>
function
CellClick(text, value) {
//it will fire whenever you are clicking on the item text
//write your code
var
list = $find(
"<%=RadListBox1.ClientID %>"
);
list.findItemByValue(value).set_checked(!list.findItemByValue(value).get_checked());
}
function
OnClientItemChecked1(sender, args) {
args.get_item().set_checked(!args.get_item().get_checked());
}
</script>
Thanks,
Princy.
0
Sean O'Brien
Top achievements
Rank 1
answered on 18 Oct 2013, 08:08 AM
John, I have a RadListBox that updates its checkbox column state based on clicking the list items and I made it work properly with OnClientItemSelectedIndexChanging. Something like this:
function
OnClientItemSelectedIndexChanging(sender, args) {
var
item = args.get_item();
item.set_checked(!item.get_checked());
args.set_cancel(
true
);
}
0
Julian
Top achievements
Rank 1
answered on 21 Oct 2013, 12:00 AM
Hi Sean,
Thanks that's perfect, We've got the required functionality working ok
Thanks again,
Thanks that's perfect, We've got the required functionality working ok
Thanks again,
0
Prajakta
Top achievements
Rank 1
answered on 07 Aug 2014, 12:08 PM
Thanks a lot for this solution worked for me
I was also facing same problem its solved using above code
Thank you for same
But before using the above code the item was getting selected when i click on checkbox not on its associated text
which solved now
but now the problem is now its getting selected when clicked on associated text but viceversa is not working means its not getting selected when i click on check box in my scenario both should work
I was also facing same problem its solved using above code
Thank you for same
But before using the above code the item was getting selected when i click on checkbox not on its associated text
which solved now
but now the problem is now its getting selected when clicked on associated text but viceversa is not working means its not getting selected when i click on check box in my scenario both should work