on 02-24-2014 4:40 AM
Hi Experts,
I have a table for mobile application. Table contains 4 fields for storing business data and one field which is actually check box. Now in table header there is two buttons for check all and unchecked all. I want to check all or unchecked all for corresponding button press. How to write the piece of code to achieve this requirement?
Below is my table with check box and two buttons for checked/unchecked-
Thanks & Regards,
Arindam Samanta.
I know it is an old post but,
i think that the best way select / unselect table (list row) is
// in your table contruction phase
sap.ui.getCore().byId('yourTable').setMode('MultiSelect');
// select all items
sap.ui.getCore().byId('yourTable').selectAll();
// unselect all items
sap.ui.getCore().byId('yourTable').removeSelections();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Experts,
I have found one solution for the above problem. I don't know whether it is right or wrong approach but it is working as per my requirement.
The solution is below:
$("#homePage--cB-homePage--tab-0-CbBg").addClass("sapMCbMarkChecked");
("#homePage--cB-homePage--tab-0-CbBg") - this is my id for the check box.
("sapMCbMarkChecked") - This is the class for checked.
So above code is working for select all.
Now I also need to implement the deselect all. In this case I don't have the reverse solution.
Could it be possible to deselect all through above approach which I have mentioned in this post?
Thanks in advanced..
Regards,
Arindam Samanta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arindam,
Try following on select all button event :
$('#htmlGeneratedID input:checkbox').each(function() {
$(this).attr('checked', 'checked');
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
On Select All, set the enable : true property for all the checkbox. Do the vice-versa for Select None.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have tried as you suggested. Below is my code:
$("#cB").enabled="true";
But it is not working.
I tried with this code also:$("#cB").selected="true";
This is also not working.
Another code:
this.getView().byId("cB").setSelected(true);
This is working in normal case like as screen input. But when the check box inside the table, the above piece of code is not working. Here cB is the check box.
Any idea on this scenario!!!
Regards,
Arindam Samanta.
If you're going with jQuery, then it should be
$('#id of CheckBox').prop('checked', true);
$('#id of CheckBox').prop('checked', false);
// id of checkbox
must be the one generated by UI5, not the id you specify.
this.getView().byId("cB").setSelected(true); should work in all the cases. Maybe, you're going wrong somewhere. Possible i guess your context of this might point to the table. Post your code.
Hi,
In for check box in side table:
<Table id="tab" showSeparators="All" items="-------" inset="false">
<headerToolbar>
<Toolbar>
<!-- <Label design="Bold" text="CBPassing"/> -->
<Button text="Select All" type="Default" press="checkAll" icon="sap-icon://multi-select"/>
<Button text="Select None" type="Default" press="uncheckAll" icon="sap-icon://decline"/>
</Toolbar>
</headerToolbar>
<columns>
------------------
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{Exbed}"/>
<tv:TextField value="{Exaed}"/>
<Text text="{Ecs}"/>
<Text text="{Exaddtax1}"/>
<CheckBox id="cB"/>
</cells>
</ColumnListItem>
</items>
</Table>
This is the code for method on button press event:
checkAll:function(oEvent)
{
this.getView().byId("cB").setSelected(true);
},
Regards,
Arindam Samanta.
What you're doing is correct! this.getView().byId('cB').setSelected(true); should work fine.
Maybe, you're overriding the selected property somewhere.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.