参考官方Demo:GridPanel -> Data With Details - Form Details
其主要过程
1.在GridPanel的SelectionModel段内编写DirectEvents,DirectEvents的子元素RowSelect的OnEvent属性,这里指定了后台调用的方法名称
<
SelectionModel
>
< ext:RowSelectionModel runat = " server " SingleSelect = " true " >
< DirectEvents >
< RowSelect OnEvent = " RowSelect " Buffer = " 100 " >
< EventMask ShowMask = " true " Target = " CustomTarget " CustomTarget = " #{FormPanel1} " />
< ExtraParams >
<%-- or can use params [ 2 ].id as value --%>
< ext:Parameter Name = " EmployeeID " Value = " this.getSelected().id " Mode = " Raw " />
</ ExtraParams >
</ RowSelect >
</ DirectEvents >
</ ext:RowSelectionModel >
</ SelectionModel >
< ext:RowSelectionModel runat = " server " SingleSelect = " true " >
< DirectEvents >
< RowSelect OnEvent = " RowSelect " Buffer = " 100 " >
< EventMask ShowMask = " true " Target = " CustomTarget " CustomTarget = " #{FormPanel1} " />
< ExtraParams >
<%-- or can use params [ 2 ].id as value --%>
< ext:Parameter Name = " EmployeeID " Value = " this.getSelected().id " Mode = " Raw " />
</ ExtraParams >
</ RowSelect >
</ DirectEvents >
</ ext:RowSelectionModel >
</ SelectionModel >
2.编写后台功能代码
protected
void
RowSelect(
object
sender, DirectEventArgs e)
{
string employeeID = e.ExtraParams[ " EmployeeID " ];
Employee empl = Employee.GetEmployee( int .Parse(employeeID));
this .FormPanel1.SetValues( new {
empl.EmployeeID,
empl.FirstName,
empl.LastName,
empl.Title,
ReportsTo = empl.ReportsTo.HasValue ? (Employee.GetEmployee(empl.ReportsTo.Value).LastName) : "" ,
empl.HireDate,
empl.Extension,
empl.Address,
empl.City,
empl.PostalCode,
empl.HomePhone,
empl.TitleOfCourtesy,
empl.BirthDate,
empl.Region,
empl.Country,
empl.Notes
});
}
{
string employeeID = e.ExtraParams[ " EmployeeID " ];
Employee empl = Employee.GetEmployee( int .Parse(employeeID));
this .FormPanel1.SetValues( new {
empl.EmployeeID,
empl.FirstName,
empl.LastName,
empl.Title,
ReportsTo = empl.ReportsTo.HasValue ? (Employee.GetEmployee(empl.ReportsTo.Value).LastName) : "" ,
empl.HireDate,
empl.Extension,
empl.Address,
empl.City,
empl.PostalCode,
empl.HomePhone,
empl.TitleOfCourtesy,
empl.BirthDate,
empl.Region,
empl.Country,
empl.Notes
});
}