This is a migrated thread and some comments may be shown as answers.

RadButton ToggleType Checkbox

6 Answers 87 Views
Button
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 30 Sep 2015, 03:19 PM
how I assign a RadButtonToggleState checked or unchecked with javascript

6 Answers, 1 is accepted

Sort by
0
Accepted
Danail Vasilev
Telerik team
answered on 02 Oct 2015, 09:39 AM
Hello Eric,

You can utilize the client-side API of the button - $find("ButtonID").set_checked(true)

Regards,
Danail Vasilev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Eric
Top achievements
Rank 1
answered on 06 Oct 2015, 03:31 PM
thanks
0
Eric
Top achievements
Rank 1
answered on 06 Oct 2015, 03:32 PM

how to keep selected multiple rows and not lose the selection to apply filters or pass between pages

                            <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="-1" DataSourceID="SqlDataSource1" GridLines="Both" AllowMultiRowSelection="true" GroupPanelPosition="Top" AllowFilteringByColumn="True" AllowPaging="True" Font-Size="XX-Small" PageSize="5">
                                <GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
                                <ClientSettings>
                                    <Selecting AllowRowSelect="True" />
                                    <Resizing AllowColumnResize="True" AllowResizeToFit="True" />
                                </ClientSettings>
                                <AlternatingItemStyle Font-Size="Small" />
                                <MasterTableView AutoGenerateColumns="False" DataKeyNames="IDENT_ASOC" DataSourceID="SqlDataSource1">
                                    <Columns>
                                        <telerik:GridClientSelectColumn UniqueName="Seleccionar">
                                        </telerik:GridClientSelectColumn>
                                        <telerik:GridBoundColumn DataField="IDENT_ASOC" HeaderText="ID CLIENTE" ReadOnly="True" SortExpression="IDENT_ASOC" UniqueName="IDENT_ASOC" AllowFiltering="False" AllowSorting="False">
                                            <HeaderStyle Width="100px" />
                                            <ItemStyle Width="100px"/>
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="NOM_ASOC" FilterControlAltText="Filter NOM_ASOC column" HeaderText="CLIENTE" SortExpression="NOM_ASOC" UniqueName="NOM_ASOC">
                                        </telerik:GridBoundColumn>
                                    </Columns>
                                </MasterTableView>
                                <ItemStyle Font-Size="Small" />
                            </telerik:RadGrid> 

 

0
Eric
Top achievements
Rank 1
answered on 06 Oct 2015, 03:33 PM
how to keep selected multiple rows and not lose the selection to apply filters or pass between pages
                            <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="-1" DataSourceID="SqlDataSource1" GridLines="Both" AllowMultiRowSelection="true" GroupPanelPosition="Top" AllowFilteringByColumn="True" AllowPaging="True" Font-Size="XX-Small" PageSize="5">
                                <GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
                                <ClientSettings>
                                    <Selecting AllowRowSelect="True" />
                                    <Resizing AllowColumnResize="True" AllowResizeToFit="True" />
                                </ClientSettings>
                                <AlternatingItemStyle Font-Size="Small" />
                                <MasterTableView AutoGenerateColumns="False" DataKeyNames="IDENT_ASOC" DataSourceID="SqlDataSource1">
                                    <Columns>
                                        <telerik:GridClientSelectColumn UniqueName="Seleccionar">
                                        </telerik:GridClientSelectColumn>
                                        <telerik:GridBoundColumn DataField="IDENT_ASOC" HeaderText="ID CLIENTE" ReadOnly="True" SortExpression="IDENT_ASOC" UniqueName="IDENT_ASOC" AllowFiltering="False" AllowSorting="False">
                                            <HeaderStyle Width="100px" />
                                            <ItemStyle Width="100px"/>
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="NOM_ASOC" FilterControlAltText="Filter NOM_ASOC column" HeaderText="CLIENTE" SortExpression="NOM_ASOC" UniqueName="NOM_ASOC">
                                        </telerik:GridBoundColumn>
                                    </Columns>
                                </MasterTableView>
                                <ItemStyle Font-Size="Small" />
                            </telerik:RadGrid> 
0
Danail Vasilev
Telerik team
answered on 07 Oct 2015, 11:22 AM
Hi Eric,

This can be done with some custom client-side logic. For example:

ASPX:
<form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
    <script>
        function OnCommand(sender, args) {
            if (args.get_commandName() == "Page") {
                var selectedItems = sender.get_masterTableView().get_selectedItems();
                var selectedIndexes = "";
                for (var i = 0; i < selectedItems.length; i++) {
                    var delimiter = "|";
                    if (i + 1 == selectedItems.length) {
                        delimiter = "";
                    }
                    selectedIndexes += selectedItems[i]._itemIndex + delimiter;
                }
                $get("<%=hf1.ClientID%>").value = selectedIndexes;
            }
        }
 
        function OnMasterTableViewCreated(sender, args) {
            if ($get("<%=hf1.ClientID%>").value != "") {
                var selectedIndexes = $get("<%=hf1.ClientID%>").value.split('|');
                for (var i = 0; i < selectedIndexes.length; i++) {
 
                    sender.get_masterTableView().get_dataItems()[selectedIndexes[i]].set_selected();
                }
            }
        }
    </script>
    <telerik:RadButton ID="RadButton1" runat="server" />
    <asp:HiddenField ID="hf1" runat="server" />
    <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="-1" OnNeedDataSource="RadGrid1_NeedDataSource" GridLines="Both" AllowMultiRowSelection="true" GroupPanelPosition="Top" AllowFilteringByColumn="True" AllowPaging="True" Font-Size="XX-Small" PageSize="5">
        <ClientSettings>
            <ClientEvents OnCommand="OnCommand" OnMasterTableViewCreated="OnMasterTableViewCreated" />
        </ClientSettings>
        <GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
        <ClientSettings>
            <Selecting AllowRowSelect="True" />
            <Resizing AllowColumnResize="True" AllowResizeToFit="True" />
        </ClientSettings>
        <AlternatingItemStyle Font-Size="Small" />
        <MasterTableView AutoGenerateColumns="False" DataKeyNames="IDENT_ASOC">
            <Columns>
                <telerik:GridClientSelectColumn UniqueName="Seleccionar">
                </telerik:GridClientSelectColumn>
                <telerik:GridBoundColumn DataField="IDENT_ASOC" HeaderText="ID CLIENTE" ReadOnly="True" SortExpression="IDENT_ASOC" UniqueName="IDENT_ASOC" AllowFiltering="False" AllowSorting="False">
                    <HeaderStyle Width="100px" />
                    <ItemStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="NOM_ASOC" FilterControlAltText="Filter NOM_ASOC column" HeaderText="CLIENTE" SortExpression="NOM_ASOC" UniqueName="NOM_ASOC">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
        <ItemStyle Font-Size="Small" />
    </telerik:RadGrid>
</form>

C#:
protected DataTable GetData()
{
    DataTable dt = new DataTable();
    dt.Columns.Add("IDENT_ASOC", typeof(Int32));
    dt.Columns.Add("NOM_ASOC", typeof(Int32));
    dt.Columns.Add("Month", typeof(DateTime));
 
    dt.Rows.Add(22, 1, new DateTime(DateTime.Now.Year, 1, 1));
    dt.Rows.Add(0, 3, new DateTime(DateTime.Now.Year, 2, 1));
    dt.Rows.Add(2, 4, new DateTime(DateTime.Now.Year, 3, 1));
    dt.Rows.Add(5, 0, new DateTime(DateTime.Now.Year, 4, 1));
    dt.Rows.Add(10, 0, new DateTime(DateTime.Now.Year, 5, 1));
    dt.Rows.Add(3, 6, new DateTime(DateTime.Now.Year, 5, 1));
    dt.Rows.Add(4, 9, new DateTime(DateTime.Now.Year, 5, 1));
    dt.Rows.Add(11, 15, new DateTime(DateTime.Now.Year, 5, 1));
    dt.Rows.Add(12, 21, new DateTime(DateTime.Now.Year, 5, 1));
 
    return dt;
}
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    (sender as RadGrid).DataSource = GetData();
}

In future when you have questions about different products I would like to ask you to open separate forum threads/ support tickets and choose the corresponding product type. Thus we can keep the threads clean and tidy.

Regards,
Danail Vasilev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Eric
Top achievements
Rank 1
answered on 07 Oct 2015, 01:30 PM
Thank's for your help Danail.
Tags
Button
Asked by
Eric
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Eric
Top achievements
Rank 1
Share this question
or