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

How to do the client side validation for Checkbox?

5 Answers 237 Views
Documentation and Tutorials
This is a migrated thread and some comments may be shown as answers.
sharath
Top achievements
Rank 1
sharath asked on 22 Jan 2015, 02:57 PM
Hello Admins,

I'm having a location grid user control. Each grid item contains check boxes. I can select the multiple check boxes  and delete all at once when i click on the link button which i have defined. Everything is working fine. But, if i don't select any of the checkboxes to delete or there is no data in the grid, how to do the client side validation for this scenario. Please help me in this regard.

And also whenever i select any check boxes, post back is happening. How to overcome this problem as well.

My checkbox code:
   <telerik:GridTemplateColumn UniqueName="CheckboxId"  HeaderText="View"  DataField="View" > 
                             <ItemTemplate> 
                                 <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true"/>  
                            </ItemTemplate> 
                          </telerik:GridTemplateColumn>

My checkbox code behind:

foreach (GridDataItem item in rgLocations.MasterTableView.Items)
                {
                    
                    chk = (CheckBox)item.FindControl("CheckBox1");
                    if (!chk.Checked)
                    {
                        DataRow newRowAdd = myDataTable.NewRow();
                        newRowAdd["Id"] = item["Id"].Text;
                        newRowAdd["Name"] = item["Name"].Text;
                        newRowAdd["CTID"] = item["CTID"].Text;
                        myDataTable.Rows.Add(newRowAdd);
                        myDataTable.AcceptChanges();
                    }
                }
                rgLocations.DataSource = myDataTable.DefaultView;
                rgLocations.Rebind();

My link button code:
<asp:LinkButton ID="lnkDeleteLoc" runat="server" OnClick="lnkDeleteLoc_Click">Delete the Location(s)</asp:LinkButton>

5 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 27 Jan 2015, 12:09 PM
Hi Sharath,

I've created a sample RadGrid web site to demonstrate how you can achieve the requested functionality. Please run the attached application and let me know if it helps you.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
sharath
Top achievements
Rank 1
answered on 27 Jan 2015, 04:15 PM
Thanks a lot for answering for my query. Is it possible to display something saying users that "You have not slected any checkbox to delete" when no check boxes has been selected and "There is no location added to the grid" when user tried to delete empty grid in the Java script itself instead of returning true or false. 

Regards,
Sharath
0
sharath
Top achievements
Rank 1
answered on 29 Jan 2015, 08:51 AM
Hello Eyup, could you please shed some idea for me. I'm getting JS error in browser saying that "grid.get_masterTableView().get_dataItems()" is null when i try to press delete when the grid is empty. How to overcome this problem.
0
Eyup
Telerik team
answered on 30 Jan 2015, 02:45 PM
Hi Sharath,

I will check the mentioned scenario and let you know when ready.

Thank you for your patience in advance.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Eyup
Telerik team
answered on 05 Feb 2015, 08:57 AM
Hello Sharath,

Thank you again for your patience.

I'm sending the modified version of the sample with the requested implementation.

Hope this helps.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Documentation and Tutorials
Asked by
sharath
Top achievements
Rank 1
Answers by
Eyup
Telerik team
sharath
Top achievements
Rank 1
Share this question
or