protected override void CreateChildControls()
{
if (!_error)
{
try
{
base .CreateChildControls();
if (! this .WebPartManager.DisplayMode.AllowPageDesign)
{
var gridControl =
(JqGridPhoneBookControl) Page .LoadControl(
"~/_controltemplates/IPGG.IntegrationSystem/PhoneBook/JqGridPhoneBookControl.ascx" );
gridControl.DivisionNumber = DivisionNumber;
Controls.Add(gridControl);
}
}
catch (Exception ex)
{
HandleException(ex);
}
}
}
* This source code was highlighted with Source Code Highlighter .
< input type ="hidden" id ="divisionNumberFromWebpart" value ='<%=DivisionNumber %>' />
< table id ="phoneBookGrid" ></ table >
< div id ="phoneBookPager" ></ div >
< div id ="employeeInfoContainer" >
...
</ div >
* This source code was highlighted with Source Code Highlighter .
[ServiceContract]
public interface IPhoneBookService
{
[OperationContract]
[WebInvoke(Method = "GET" , ResponseFormat = WebMessageFormat.Json)]
JqGridResult<Employee> GetAllRecordsForJqGrid();
[OperationContract]
[WebInvoke(Method = "GET" )]
Stream GetPhoto( int employeeId);
[OperationContract]
[WebInvoke(Method = "GET" , ResponseFormat = WebMessageFormat.Json)]
Employee GetRecord( int employeeId);
}
* This source code was highlighted with Source Code Highlighter .
[DataContract]
public class JqGridResult<T>
{
[DataMember]
public int CurrentPage { get ; set ; }
[DataMember]
public int TotalPages { get ; set ; }
[DataMember]
public int TotalRecords { get ; set ; }
[DataMember]
public List <T> Records { get ; set ; }
}
* This source code was highlighted with Source Code Highlighter .
<? xml version ="1.0" ? >
< configuration >
< system.serviceModel >
< behaviors >
< serviceBehaviors >
< behavior name ="serviceBehavior" >
< serviceMetadata httpGetEnabled ="true" />
< serviceDebug includeExceptionDetailInFaults ="true" />
</ behavior >
</ serviceBehaviors >
< endpointBehaviors >
< behavior name ="endpointBehavior" >
< webHttp />
</ behavior >
</ endpointBehaviors >
</ behaviors >
< services >
< service name ="IPGG.IntegrationSystem.Web.Services.PhoneBookService" behaviorConfiguration ="serviceBehavior" >
< endpoint address ="" binding ="webHttpBinding" contract ="IPGG.IntegrationSystem.Web.Services.IPhoneBookService" behaviorConfiguration ="endpointBehavior" />
</ service >
</ services >
</ system.serviceModel >
</ configuration >
* This source code was highlighted with Source Code Highlighter .
$( "#phoneBookGrid" ).jqGrid({
url: "/_layouts/IPGG.IntegrationSystem/PhoneBookService.svc/GetAllRecordsForJqGrid" ,
datatype: "json" ,
jsonReader: gridJsonReader,
colNames: columnNames,
colModel: columns,
width: 850,
height: 460,
shrinkToFit: false ,
pager: "#phoneBookPager" ,
rowList: [20, 50, 100, 1000],
onSelectRow: GetEmployeeDetails,
loadComplete: gridLoaded
}).navGrid( "#phoneBookPager" , { add: false , edit: false , del: false , search: false , refresh: true }).filterToolbar();
$( "#phoneBookGrid" ).jqGrid( "navButtonAdd" , "#phoneBookPager" , {
caption: "/ " ,
title: " " ,
onClickButton: function () {
$( "#phoneBookGrid" ).jqGrid( "columnChooser" );
}
});
$( "#employeeInfoContainer" ).dialog({
bgiframe: true ,
modal: true ,
autoOpen: false ,
width: 550,
resizable: false ,
close: ClearDialog,
buttons: {
Ok: function () {
$( this ).dialog( 'close' );
}
}
});
* This source code was highlighted with Source Code Highlighter .
var gridJsonReader = {
root: "Records" ,
page: "CurrentPage" ,
total: "TotalPages" ,
records: "TotalRecords" ,
repeatitems: false ,
id: "Id"
};
* This source code was highlighted with Source Code Highlighter .
function GetEmployeeDetails(id) {
$( "#employeeInfoContainer" ).dialog( "open" );
$.ajax({
url: "/_layouts/IPGG.IntegrationSystem/PhoneBookService.svc/GetRecord" ,
data: "employeeId=" + id,
success: ProcessInfo,
error: ProcessError
});
GetImage(id);
...
}
* This source code was highlighted with Source Code Highlighter .
function GetImage(employeeId) {
$( "#employeeImage" ).attr( "src" , "/_layouts/IPGG.IntegrationSystem/PhoneBookService.svc/GetPhoto?employeeId=" + employeeId);
}
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/84848/