| function RowSelected(sender, args) { |
| var ajaxManager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>"); |
| ajaxManager.ajaxRequest('StrgShiftCombinationPressed'); |
| } |
Hi,
I have a RADGRID with a DATABIND client-side.
The databind event is raised with a JS SETTIMEOUT function:
setTimeout('bindGrid()', 5000);
and in a bindGrid I have a regular call to my web service:
WS.GetDocumentsSelected(startIndex, pageSize, sortField, sortOrder, filtroT, filtroM, mozione, updateGrid, koMessage);
where filtroT, filtroM, mozione are a custom filter.
The return of WS is a below code
| function updateGrid(result) { |
| var tableView = $find("<%=RadGrid1.ClientID %>").get_masterTableView(); |
| tableView.set_dataSource(result); |
| tableView.dataBind(); |
| } |
It's work fine, but I have a problem with selected row:
If I selected the second row, e.g., and I execute a sort command, my row selected persist in the second row.
The same problem occours with paging-change and a filter changed.
I try to save my selected-row id in hidden-field and in data bound function set the selection manually with the follow code:
| function RadGrid1_RowDataBound(sender, args) { |
| var dkvs = document.getElementById("<%=DataKeyValueSelected.ClientID%>"); |
| if (dkvs && dkvs.value && (args.get_dataItem()["Id_doc"] == dkvs.value)) { |
| //args.get_dataItem().set_selected(true); |
| sender.get_masterTableView().get_dataItems()[parseInt(args.get_item()._itemIndexHierarchical)].set_selected(true); |
| } else { |
| //args.get_dataItem().set_selected(false); |
| sender.get_masterTableView().get_dataItems()[parseInt(args.get_item()._itemIndexHierarchical)].set_selected(false); |
| } |
| } |
after data bound the paging-change and a sort works fine, but if after row selected I remove my filter, I have all alternating item selected (after the selected row - see attached) .....
| <telerik:radgrid ID="RadGrid1" runat="server" Height="300" Visible="true" BackColor="LightBlue" ShowFooter="true" PageSize="20" AllowPaging="True" AllowFilteringByColumn="True" AllowSorting="true" ShowStatusBar="true" GridLines="None" AutoGenerateColumns="False" Skin="Vista" OnPreRender="RadGrid1_PreRender" OnItemDataBound ="RadGrid1_ItemDataBound" OnItemCreated="RadGrid1_ItemCreated" OnNeedDataSource="RadGrid1_NeedDataSource" OnColumnCreated="RadGrid1_ColumnCreated" > |
| <MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="false" AllowFilteringByColumn="True" AllowSorting="true" > |
| <ExpandCollapseColumn><HeaderStyle Width="20px"></HeaderStyle></ExpandCollapseColumn> |
| <RowIndicatorColumn><HeaderStyle Width="20px" /></RowIndicatorColumn> |
| <ExpandCollapseColumn><HeaderStyle Width="20px" /></ExpandCollapseColumn> |
| <Columns> |
| <%-- <telerik:GridDropDownColumn DataField="a" HeaderText="a" UniqueName="a" />--%> |
| <telerik:GridDropDownColumn DataField="a" HeaderText="a" UniqueName="a" ListTextField="a" ListValueField="a" DataSourceID="SqlDataSource1"/> |
| <telerik:GridBoundColumn DataField="b" HeaderText="b" UniqueName="b" /> |
| <telerik:GridBoundColumn DataField="c" HeaderText="c" UniqueName="c" /> |
| <telerik:GridBoundColumn DataField="d" HeaderText="d" UniqueName="d" /> |
| protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridEditFormItem && e.Item.IsInEditMode) |
| { |
| string[] strArray = { "a", "e"}; |
| GridEditFormItem item = (GridEditFormItem)e.Item; |
| for (int k = 0; k < 2; k++) |
| { |
| GridDropDownListColumnEditor editor = (GridDropDownListColumnEditor)item.EditManager.GetColumnEditor(strArray[k]); |
| editor.DataSource = (DataSet)Session["sesds"]; |
| editor.DataTextField = strArray[k]; |
| editor.DataValueField = strArray[k]; |
| editor.DataBind(); |
| editor.ComboBoxControl.AutoPostBack = true; |
| editor.ComboBoxControl.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(ComboBoxControl_SelectedIndexChanged); |
| } |
| } |
| } |
| protected void ComboBoxControl_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) |
| { |
| try |
| { |
| //string ElementID = Convert.ToString((sender as RadComboBox).SelectedItem.Text); |
| RadComboBox rad = (RadComboBox)o; |
| GridEditableItem editedItem = (GridEditableItem)(o as RadComboBox).NamingContainer; |
| GridEditManager editMan = editedItem.EditManager; |
| foreach (GridColumn column in RadGrid1.MasterTableView.RenderColumns) |
| { |
| if (column is IGridEditableColumn) |
| { |
| IGridEditableColumn editableCol = (column as IGridEditableColumn); |
| if (editableCol.IsEditable) |
| { |
| IGridColumnEditor editor = editMan.GetColumnEditor(editableCol); |
| if (editor is GridTextColumnEditor) |
| { |
| if ( rad.ID.ToLower() == "rcb_a") |
| { |
| if (column.UniqueName == "b") |
| { |
| (editor as GridTextColumnEditor).Text = "Done"; |
| } |
| else if (column.UniqueName == "c") |
| { |
| (editor as GridTextColumnEditor).Text = "ok"; |
| } |
| else if (column.UniqueName == "d") |
| { |
| (editor as GridTextColumnEditor).Text = "ok1"; |
| } |
| } |
| if (rad.ID.ToLower() == "rcb_e") |
| { |
| if (column.UniqueName == "f") |
| { |
| (editor as GridTextColumnEditor).Text = "Done2"; |
| } |
| else if (column.UniqueName == "g") |
| { |
| (editor as GridTextColumnEditor).Text = "ok2"; |
| } |
| else if (column.UniqueName == "h") |
| { |
| (editor as GridTextColumnEditor).Text = "ok3"; |
| (editor as GridTextColumnEditor).Visible = false; |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| catch |
| { |
| } |
| } |
GetRadWindow().BrowserWindow.location.href = GetRadWindow().BrowserWindow.location.href;
to reload the page so that any changes take effect. The problem is it relaods the whole page and resets any paramters that may be selected in a series of dropdowns. All I want to do is refresh the Repeater contol with Ajax from the RadWindow close.
How would I go about doing this.
Andy