Hi team,
I am using the webdatagrid in my solution. I have a functionlaity in which i have added unbound checkbox field for every row in the grid. The user can select each row by ticking the checkbox field
I have to however lay 2 restrictions
1) The user should be able to check at the most 5 chekckbox at a time. For this i was trying to find any client side event which fires when a user clicks on a checkbox. However i couldnt find any event which does this and hence i am not sure as to how to lay this retriction
2) WHen user selects the rows by ticking the checkbox, i want to get the row field values for the checked fields. How do i achieve this ?
Also there is another query i had.By default,when i click on a checkbox it shows an X in that checkbox. How do i put a tick mark instead of the X mark?
Kindly guide me in the above 3 tasks. Thanks
For the last part of showing a different image , i know how to use a different image, but when we install infragistics tool set are there any default images which are added ? Or Do i need to search on net to find an image to be used? Thanks
Hi Team,
Can you please help me with task 1 and task 2 as i have described above. I tried looking through your forums,documentation , tried it myself but no luck.
I am sharing my webdatagrid code below. Can you please guide me how do i get the checked rows in javascript
<ig:WebDataGrid ID="RoleDataGrid" runat="server" Height="420px" Width="100%" AutoGenerateColumns="False" > <Columns> <ig:UnboundCheckBoxField Key="UnboundCheckBoxField" HeaderCheckBoxMode="Off"> <Header Text="Click to Select" /> </ig:UnboundCheckBoxField> <ig:BoundDataField DataFieldName="RoleName" Key="RoleName"> <Header Text="Role Name" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="RolePurpose" HtmlEncode="False" Key="RolePurpose"> <Header Text="Role Purpose" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="KeyResponsibilities" HtmlEncode="False" Key="KeyResponsibilities"> <Header Text="Key Responsibilities" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="CareerTrack" HtmlEncode="False" Key="CareerTrack"> <Header Text="Career Track" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="TalentSegment" HtmlEncode="False" Key="TalentSegment"> <Header Text="Talent Segment" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="CareerLevel" HtmlEncode="False" Key="CareerLevel"> <Header Text="Career Level" /> </ig:BoundDataField> </Columns> <Behaviors> <ig:ColumnResizing> </ig:ColumnResizing> <ig:Filtering> <ColumnSettings> <ig:ColumnFilteringSetting ColumnKey="UnboundCheckBoxField" Enabled="False" /> </ColumnSettings> </ig:Filtering> <ig:Paging PageSize="20" PagerMode="NumericFirstLast"> </ig:Paging> <ig:Sorting> <ColumnSettings> <ig:SortingColumnSetting ColumnKey="UnboundCheckBoxField" Sortable="False" /> </ColumnSettings> </ig:Sorting> <ig:EditingCore> <EditingClientEvents CellValueChanged="RoleDataGrid_Editing_CellValueChanged" /> <Behaviors> <ig:CellEditing> <ColumnSettings> <ig:EditingColumnSetting ColumnKey="UnboundCheckBoxField" /> <ig:EditingColumnSetting ColumnKey="RoleName" ReadOnly="True" /> <ig:EditingColumnSetting ColumnKey="RolePurpose" ReadOnly="True" /> <ig:EditingColumnSetting ColumnKey="KeyResponsibilities" ReadOnly="True" /> <ig:EditingColumnSetting ColumnKey="CareerTrack" ReadOnly="True" /> <ig:EditingColumnSetting ColumnKey="CareerLevel" ReadOnly="True" /> <ig:EditingColumnSetting ColumnKey="TalentSegment" ReadOnly="True" /> </ColumnSettings> <CellEditingClientEvents/> <EditModeActions MouseClick="Single" /> </ig:CellEditing> </Behaviors> </ig:EditingCore> </Behaviors> <ErrorTemplate> Oops... there was an error encountered.Please try again later! </ErrorTemplate> <EmptyRowsTemplate> Your query produced no results. </EmptyRowsTemplate> </ig:WebDataGrid>
Hi yadusaxena,
The client event that fires when a checkbox is clicked is the EditingCore's client event value changing/changed. You're already handling changed. If you want to cap it at 5, simply handle changing and incremenet a counter. If it goes more than 5, cancel the event. args.set_cancel(true); In the value changed event, the event args has a reference to the cell, and from the cell you can get the row, and then any other cells and their values.
regards,
David Young
Thanks David,thanks for the response.However i would like to clarify more on what you said.
Firstly, is there any other way of getting as to how many checkboxes are ticked.Is there some property of the grid or some other property which would give me the count of the checkboxes ticked? If it is then it would be a direct and easy way.With incrementing the counter there could be problems if a user later unchecks a box which was selected by him.
Secondly,i am handling the editing core's event which is fired whenver i check a checkbox.I handle the event client side and try and get the selected row through the event args parameter. I have tried extensively but still no luck.I went through the documentation but couldnt find anything relevant there either. I am pasting my code for handling the client event. Can you please help me as to how do i get the selected row ? Thanks
function RoleDataGrid_Editing_CellValueChanged(sender, eventArgs) { //Add code to handle your event here. grid = $find("<%= RoleDataGrid.ClientID %>"); selectedRow = grid.get_behaviors().get_editingCore(); editedRows = selectedRow.get_editedRows(); alert('Hello') }
Hi,
To get the row, do as I said. eventArgs.get_cell().get_row();
For the checked count, if you get the unbound checkbox column, there is a get_checkedCount() on the column object.
Thanks for your reply david.For getting the checked count, i tried the above. eventArgs.get_cell().get_column().get_checkedCount() . However this returns 0 each time. Isnt that strange ?