or
Please find the code snippet of webservice. [asmx page]
| [WebMethod(EnableSession = true)] |
| public List<AdminSettingsCategoryEntity> DeleteSelectedCategories(string strSelectedCateoryList, string modifiedBy, string clientID) |
| { |
| int intCatgIsUsed = 0; |
| int intCatgID = 0; |
| GridTableView CategoryGridMaterTableView = new GridTableView(); |
| System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); |
| var jsIds = serializer.Deserialize<Dictionary<string, object>>(strSelectedCateoryList); |
| if (jsIds != null) |
| { |
| ArrayList selectedItems = new ArrayList(); |
| foreach (KeyValuePair<string, object> keyValuePair in jsIds) |
| selectedItems.Add(long.Parse(keyValuePair.Key)); |
| if (selectedItems.Count > 0) |
| { |
| //Functionality to remove the selected Category IDS and updating list<bussinessEntity> |
| } |
| //return usersDraftList.ToList(); |
| } |
| return categoryList.ToList(); |
| } |
| <div id="divdgListOfCategory" runat="server" style="width: 420px; float: left; margin-bottom: 7px; |
| height: 180px;"> |
| <telerik:RadGrid ID="DgListOfCategory" runat="server" AutoGenerateColumns="false" AllowMultiRowSelection="true" AllowPaging="false" PagerStyle-Visible="false" |
| Skin="GridVista" EnableViewState="true" Width="412px" AllowMultiRowEdit="true" EnableEmbeddedSkins="false" |
| OnItemDataBound="DgListOfCategory_ItemDataBound" OnItemCommand="DgListOfCategory_ItemCommand"> |
| <MasterTableView Width="395px" AutoGenerateColumns="false" EditMode="InPlace" |
| NoMasterRecordsText="No Records Found" AllowAutomaticDeletes="True" DataKeyNames="ID" |
| AllowAutomaticInserts="false" AllowAutomaticUpdates="false" ShowHeadersWhenNoRecords="true" ClientDataKeyNames="ID,isUsed" |
| CommandItemDisplay="Top"> |
| <CommandItemTemplate> |
| <div id="lnkAddrows" style="float:left;line-height: 29px;"> |
| <asp:LinkButton ID="btnAddNewRecord" runat="server" CommandName="AddNewRecord" Style="vertical-align: bottom"> |
| <asp:Image ID="imgAdd" runat="server" ImageUrl="~/Images/AddRecord.gif" />Add New Record</asp:LinkButton> |
| </div> |
| <div id="divDeleteRows" style="float:left;line-height: 29px;padding-left:30px;"> |
| <asp:LinkButton ID="lnkDeleteRows" runat="server" Style="vertical-align: bottom" OnClientClick="javascript:return DgListOfCategoryDeleteSelectedRows()" > |
| <asp:Image ID="imgDelete" runat="server" ImageUrl="~/Images/val_close.png" /> Delete</asp:LinkButton> |
| </div> |
| </CommandItemTemplate> |
| <Columns> |
| <telerik:GridClientSelectColumn UniqueName="CheckboxSelectColumn" HeaderStyle-Width="40px" |
| ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center" > |
| </telerik:GridClientSelectColumn> |
| <telerik:GridTemplateColumn UniqueName="Active" HeaderText="Select" DataType="System.Int32" |
| HeaderStyle-Width="40px" ItemStyle-Width="40px" ItemStyle-HorizontalAlign="Center"> |
| <ItemTemplate> |
| <asp:CheckBox ID="chkActive" runat="server" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn UniqueName="tempCatgName" HeaderText="Category Name" |
| DataType="System.String" ReadOnly="False" HeaderStyle-Width="160px" ItemStyle-Width="160px"> |
| <ItemTemplate> |
| <telerik:RadTextBox ID="CategoryName" Text='<%#Eval("CategoryName") %>' runat="server" |
| EmptyMessage="Category Name" MaxLength="50" Width="145px"> |
| </telerik:RadTextBox> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="ID" HeaderText="ID" ReadOnly="True" AllowSorting="false" |
| Visible="false" ItemStyle-Width="0" HeaderStyle-Width="0" UniqueName="ID"> |
| <HeaderStyle ForeColor="Silver" /> |
| <ItemStyle ForeColor="Silver" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="isUsed" HeaderText="isUsed" ItemStyle-Width="5" |
| HeaderStyle-Width="5" Visible="false" UniqueName="isUsed"> |
| </telerik:GridBoundColumn> |
| <telerik:GridClientDeleteColumn HeaderStyle-Width="40px" ButtonType="ImageButton" HeaderText="Delete" |
| CommandName="Delete" Text="Delete" UniqueName="DeleteColumn" > |
| <HeaderStyle Width="40px" /> |
| <ItemStyle HorizontalAlign="Center" Width="30px" /> |
| </telerik:GridClientDeleteColumn> |
| </Columns> |
| </MasterTableView> |
| <ClientSettings> |
| <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" ScrollHeight="174px"> |
| </Scrolling> |
| <Selecting AllowRowSelect="true" /> |
| <ClientEvents OnRowSelected="DgListOfCategory_RowSelected" OnRowCreated="DgListOfCategory_RowCreated" |
| OnRowDeselected="DgListOfCategory_RowDeselected" OnRowDeleted="DgListOfCategory_RowDeleted" /> |
| <DataBinding Location="CategoryPopUp.aspx" SelectCountMethod="MyFirstPageMethod"/> |
| </ClientSettings> |
| </telerik:RadGrid> |
| </div> |
| <script src="../../JavaScripts/jquery-1.3.2.min.js" type="text/javascript"></script> |
| <script src="../../JavaScripts/json2.js" type="text/javascript"></script> |
| <script src="../../JavaScripts/jquery-1.2.6.pack.js" type="text/javascript"></script> |
| <script type="text/javascript" language="javascript"> |
| var commandName = ""; |
| var tableView = null; |
| var clientIDValue = null; |
| var SelectedCatgIDs = null |
| var selected = {}; |
| var userIDValue = null; |
| function DgListOfCategory_RowSelected(sender, args) { |
| var mailID = args.getDataKeyValue("ID"); |
| if (!selected[mailID]) { |
| selected[mailID] = true; |
| } |
| // Set the value of the hidden variable to |
| // the value of the javascript variable |
| var hiddenControl = '<%= selectedInstrumentIds.ClientID %>'; |
| document.getElementById(hiddenControl).value = Sys.Serialization.JavaScriptSerializer.serialize(selected); |
| } |
| function DgListOfCategory_RowDeselected(sender, args) { |
| var mailID = args.getDataKeyValue("ID"); |
| if (selected[mailID]) { |
| selected[mailID] = null; |
| } |
| // Set the value of the hidden variable to |
| // the value of the javascript variable |
| var hiddenControl = '<%= selectedInstrumentIds.ClientID %>'; |
| document.getElementById(hiddenControl).value = Sys.Serialization.JavaScriptSerializer.serialize(selected); |
| } |
| function DgListOfCategory_RowCreated(sender, args) { |
| var mailID = args.getDataKeyValue("ID"); |
| if (selected[mailID]) { |
| args.get_gridDataItem().set_selected(true); |
| } |
| } |
| function DgListOfCategory_RowDeleted(sender, args) |
| { |
| alert("Delete Cliecked"); |
| var mailID = args.getDataKeyValue("ID"); |
| if (!selected[mailID]) { |
| selected[mailID] = true; |
| } |
| // Set the value of the hidden variable to |
| // the value of the javascript variable |
| var hiddenControl = '<%= selectedInstrumentIds.ClientID %>'; |
| document.getElementById(hiddenControl).value = Sys.Serialization.JavaScriptSerializer.serialize(selected); |
| } |
| function DgListOfCategoryDeleteSelectedRows() |
| { |
| tableView = $find("<%= DgListOfCategory.ClientID %>").get_masterTableView(); |
| clientIDValue = document.getElementById("ctl00_plhMainContentArea_hdnClientID").value; |
| userIDValue = document.getElementById("ctl00_plhMainContentArea_hdnUserID").value; |
| SelectedCatgIDs = document.getElementById("ctl00_plhMainContentArea_selectedInstrumentIds").value; |
| var DataItems = $find("<%=DgListOfCategory.ClientID %>").get_masterTableView().get_dataItems(); |
| if(DataItems != null) |
| { |
| executeMethod("../../WebServices/SettingsWebService.asmx", "DeleteSelectedCategories", getRequestData(tableView), updateGrid); |
| } |
| } |
| function updateGrid(result) |
| { |
| tableView.set_dataSource(result.d); |
| tableView.dataBind(); |
| } |
| function getRequestData(tableView) { |
| return JSON.stringify({ |
| "strSelectedCateoryList": SelectedCatgIDs, |
| "modifiedBy" : userIDValue, |
| "clientID" : clientIDValue |
| }); |
| } |
| function executeMethod(location, methodName, methodArguments, onSuccess, onFail) |
| { |
| $.ajax({ |
| type: "POST", |
| url: location + "/" + methodName, |
| data: methodArguments, |
| contentType: "application/json; charset=utf-8", |
| dataType: "json", |
| success: onSuccess, |
| fail: onFail |
| }); |
| } |
| </script> |
| var dataItem = oExplorer.get_grid().get_masterTableView().get_selectedItems()[0].get_dataItem(); |
| var status = dataItem.Attributes["Status"]; |
| if (selectedItem.get_type() == Telerik.Web.UI.FileExplorerItemType.File) { |
| alert('How do I get the Attributes here?'); |
| } |

| <%@ Control AutoEventWireup="false" CodeBehind="wucCompteHistoPrets.ascx.vb" Inherits="OPAC_LOCAL.wucCompteHistoPrets" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <asp:Panel ID="PanelHistoPrets" runat="server"> |
| <asp:label id="MSG_ERREUR" runat="server" CssClass="MessageErreur" Visible="False"></asp:label> |
| <telerik:RadGrid id="GrilleHistoPrets" runat="server" EnableEmbeddedSkins="false" Width="100%" Skin="Default" |
| PageSize="20" PagerStyle-AlwaysVisible="true" AllowPaging="true" AutoGenerateColumns="false" |
| GroupingEnabled="false" ShowGroupPanel="false" AllowMultiRowSelection="true" AllowSorting="true" |
| ClientSettings-AllowDragToGroup="false" ClientSettings-Selecting-AllowRowSelect="true" |
| SortingSettings-SortToolTip="Cliquer pour trier la colonne" SortingSettings-SortedDescToolTip="Tri ascendant" SortingSettings-SortedAscToolTip="Tri descendant" |
| OnNeedDataSource="GrilleHistoPrets_NeedDataSource" OnItemDataBound="GrilleHistoPrets_ItemDataBound" |
| OnItemCreated="GrilleHistoPrets_ItemCreated" |
| OnItemCommand="GrilleHistoPrets_ItemCommand" |
| ShowStatusBar="true" |
| > |
| <MasterTableView PageSize="20" runat="server" |
| AllowAutomaticDeletes="false" AllowAutomaticInserts="false" AllowAutomaticUpdates="false" |
| NoMasterRecordsText="Aucun prêt" NoDetailRecordsText="Aucun prêt" |
| ShowHeadersWhenNoRecords="true" |
| CommandItemDisplay="Top" |
| > |
| <Columns> |
| </Columns> |
| <CommandItemTemplate> |
| <div align="right" style="padding:4px 0px 0px 6px;"> |
| <asp:ImageButton runat="server" ID="btnClearFilters" CommandName="ClearFilters" /> |
| <asp:Button runat="server" ID="btnTexteClearFilters" CommandName="ClearFilters" /> |
| </div> |
| </CommandItemTemplate> |
| </MasterTableView> |
| <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" |
| FirstPageText="" FirstPageToolTip="Aller à la première page" |
| NextPageText="" NextPageToolTip="Aller à la page suivante" |
| LastPageText="" LastPageToolTip="Aller à la dernière page" |
| PrevPageText="" PrevPageToolTip="Aller à la page précédente" |
| NextPagesToolTip="Afficher les pages suivantes" PrevPagesToolTip="Afficher les pages précédentes" |
| PagerTextFormat="{4}{5} prêt(s) sur {1} page(s)" |
| /> |
| </telerik:RadGrid> |
| </asp:Panel> |
| Protected Sub AfficherGrillePrets() |
| Dim i As Integer = 0 |
| Dim strTxt As String = "" |
| SessionsConfig.GetConfTextes("TexteAucunPret", strTxt) |
| GrilleHistoPrets.MasterTableView.NoDetailRecordsText = strTxt |
| GrilleHistoPrets.MasterTableView.NoMasterRecordsText = strTxt |
| GrilleHistoPrets.MasterTableView.Columns.Clear() |
| GrilleHistoPrets.AllowFilteringByColumn = _AutoriserFiltrage |
| If Not IsNothing(ListeColonneHistoPrets) AndAlso ListeColonneHistoPrets.Count > 0 Then |
| Dim colID As GridBoundColumn |
| colID = New GridBoundColumn |
| colID.DataField = "Id" |
| colID.Visible = False |
| GrilleHistoPrets.MasterTableView.Columns.Add(colID) |
| Dim myEnum As IEnumerator = ListeColonneHistoPrets.GetEnumerator() |
| Dim sLibCol As String |
| Dim sTypeCol As String = "T" |
| i = 1 |
| While myEnum.MoveNext |
| sLibCol = CStr(myEnum.Current) |
| sTypeCol = "T" |
| If CStr(myEnum.Current).Contains("|") Then |
| Try |
| sLibCol = CStr(myEnum.Current).Split("|")(0) |
| sTypeCol = CStr(myEnum.Current).Split("|")(1) |
| Catch ex As Exception |
| End Try |
| End If |
| Select Case sTypeCol |
| Case "T" |
| Dim col As New GridBoundColumn |
| col.DataField = "val" & i |
| col.HeaderText = sLibCol |
| col.ItemStyle.HorizontalAlign = HorizontalAlign.Left |
| col.AllowFiltering = False |
| GrilleHistoPrets.MasterTableView.Columns.Add(col) |
| Case "D" |
| Dim col As New GridDateTimeColumn |
| col.DataField = "valD" & i |
| col.DataType = GetType(System.DateTime) |
| col.DataFormatString = "{0:dd/MM/yyyy}" |
| col.HeaderText = sLibCol |
| col.AllowFiltering = False |
| col.ItemStyle.HorizontalAlign = HorizontalAlign.Left |
| GrilleHistoPrets.MasterTableView.Columns.Add(col) |
| Case "TF" |
| Dim col As New CustomFilterForTextGridColumn(ListeLigneHistoPrets, "val" & i) |
| col.DataField = "val" & i |
| col.HeaderText = sLibCol |
| col.AllowFiltering = _AutoriserFiltrage |
| col.ItemStyle.HorizontalAlign = HorizontalAlign.Left |
| GrilleHistoPrets.MasterTableView.Columns.Add(col) |
| Case "DF" |
| Dim col As New CustomFilterForDateGridColumn(ListeLigneHistoPrets, "valD" & i) |
| col.DataField = "valD" & i |
| col.DataType = GetType(System.DateTime) |
| col.DataFormatString = "{0:dd/MM/yyyy}" |
| col.HeaderText = sLibCol |
| col.AllowFiltering = _AutoriserFiltrage |
| col.ItemStyle.HorizontalAlign = HorizontalAlign.Left |
| GrilleHistoPrets.MasterTableView.Columns.Add(col) |
| End Select |
| i += 1 |
| End While |
| End If |
| End Sub |
| Imports Telerik.Web.UI |
| Public Class CustomFilterForDateGridColumn |
| Inherits GridBoundColumn |
| Private _DataTable As List(Of PODCompteEntite) |
| Private _DataField As String |
| Private Property _DateDebut() As String |
| Get |
| Return CStr(System.Web.HttpContext.Current.Session("DateDebut" & Me.UniqueName)) |
| End Get |
| Set(ByVal value As String) |
| System.Web.HttpContext.Current.Session("DateDebut" & Me.UniqueName) = value |
| End Set |
| End Property |
| Private Property _DateFin() As String |
| Get |
| Return CStr(System.Web.HttpContext.Current.Session("DateFin" & Me.UniqueName)) |
| End Get |
| Set(ByVal value As String) |
| System.Web.HttpContext.Current.Session("DateFin" & Me.UniqueName) = value |
| End Set |
| End Property |
| Public Sub New(ByVal pDataTable As List(Of PODCompteEntite), ByVal pDataField As String) |
| _DataTable = pDataTable |
| _DataField = pDataField |
| End Sub |
| Protected Overrides Sub SetupFilterControls(ByVal cell As System.Web.UI.WebControls.TableCell) |
| MyBase.SetupFilterControls(cell) |
| cell.Controls.RemoveAt(0) |
| Dim dateDebut As New RadDatePicker() |
| dateDebut.ID = "dateDebut" & Me.UniqueName |
| dateDebut.Width = Unit.Pixel(100) |
| dateDebut.AutoPostBack = False |
| Dim dateFin As New RadDatePicker() |
| dateFin.ID = "dateFin" & Me.UniqueName |
| dateFin.Width = Unit.Pixel(100) |
| dateFin.AutoPostBack = False |
| Dim sChargement As String = "" |
| SessionsConfig.GetConfTextes("TexteChargementEnCours", sChargement) |
| cell.Controls.AddAt(0, New LiteralControl("<div align=""right"">De ")) |
| cell.Controls.AddAt(1, dateDebut) |
| cell.Controls.AddAt(2, New LiteralControl("</div>")) |
| cell.Controls.AddAt(3, New LiteralControl("<div align=""right"">A ")) |
| cell.Controls.AddAt(4, dateFin) |
| cell.Controls.AddAt(5, New LiteralControl("</div>")) |
| cell.Controls.AddAt(6, New LiteralControl("<div align=""right"">")) |
| Dim btnFiltrer As New ImageButton |
| btnFiltrer.ID = "btnFiltrer" & Me.UniqueName |
| cell.Controls.AddAt(7, btnFiltrer) |
| cell.Controls.AddAt(8, New LiteralControl("</div>")) |
| cell.Controls.RemoveAt(9) |
| End Sub |
| Protected Overrides Sub SetCurrentFilterValueToControl(ByVal cell As System.Web.UI.WebControls.TableCell) |
| MyBase.SetCurrentFilterValueToControl(cell) |
| Dim dateDebut As RadDatePicker = CType(cell.Controls(1), RadDatePicker) |
| If _DateDebut <> String.Empty Then |
| dateDebut.SelectedDate = Date.Parse(_DateDebut) |
| End If |
| Dim dateFin As RadDatePicker = CType(cell.Controls(4), RadDatePicker) |
| If _DateFin <> String.Empty Then |
| dateFin.SelectedDate = Date.Parse(_DateFin) |
| End If |
| End Sub |
| Protected Overrides Function GetCurrentFilterValueFromControl(ByVal cell As System.Web.UI.WebControls.TableCell) As String |
| Dim sDate As String = String.Empty |
| _DateDebut = String.Empty |
| _DateFin = String.Empty |
| Dim dateDebut As RadDatePicker = CType(cell.Controls(1), RadDatePicker) |
| Dim dateFin As RadDatePicker = CType(cell.Controls(4), RadDatePicker) |
| If Not IsNothing(dateDebut.SelectedDate) Then |
| sDate = dateDebut.SelectedDate.ToString() |
| _DateDebut = dateDebut.SelectedDate.ToString() |
| End If |
| If Not IsNothing(dateFin.SelectedDate) Then |
| _DateFin = dateFin.SelectedDate.ToString() |
| sDate = dateFin.SelectedDate.ToString() |
| End If |
| Return sDate |
| End Function |
| Private Sub BoutonFiltrer_Command(ByVal sender As Object, ByVal e As CommandEventArgs) |
| Dim filterItem As GridFilteringItem = CType(CType(sender, ImageButton).NamingContainer, GridFilteringItem) |
| filterItem.FireCommandEvent("Filter", New Pair("GreaterThan", Me.UniqueName)) |
| End Sub |
| End Class |

