1、js(Ext)操作
Ext.Msg.alert('系统提示', '未连接血站,该功能暂时不能使用。');
Ext.getCmp("id").getValue();
Ext.getCmp("id").focus();
Ext.getCmp("id").selectText();
//选中修改
if (!GridPanel1.hasSelection()) {
Ext.Msg.alert("系统提示", "请选择记录!");
return;
}
var record = GridPanel1.selModel.getSelected();
alert(record.data.BULLETIN_ID);
2、后置类选择提示窗口
X.Msg.Confirm("系统提示", "确认保存复检信息?", new MessageBoxButtonsConfig
{
Yes = new MessageBoxButtonConfig
{
Handler = "Ext.net.DirectMethods.DoYes()",
Text="是"
},
No = new MessageBoxButtonConfig
{
Handler = "Ext.net.DirectMethods.DoNo()",
Text = "否"
}
}).Show();
3、GridPanel添加事件
方式一:
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server">
<Listeners>
<RowSelect handler="alert(record.data.BAR_CODE);" />
</Listeners>
</ext:RowSelectionModel>
</SelectionModel>
方式二:
<Listeners>
<DblClick Fn="OnGpRowClick" />
</Listeners> <script type="text/javascript">
function OnGpRowClick(grid, rowIndex, e) {
alert(GridPanel1.getSelectionModel().getSelected().data.DAY_ID);
}
</script>
4、GridPanel分组展示+汇总信息
<ext:GridPanel ID="GridPanel1" runat="server" Collapsible="false" Width="" Height=""
AutoExpandColumn="OPERATE_NAME" Frame="true">
<Store>
<ext:Store ID="Store1" runat="server" GroupField="OPERATE_NAME">
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name="OPERATE_NAME" />
<ext:RecordField Name="USAGE_AMOUNT" />
<ext:RecordField Name="DOCTOR_NAME" />
<ext:RecordField Name="DEPT_NAME" />
<ext:RecordField Name="USAGE_AMOUNT" />
<ext:RecordField Name="LISHU" />
<ext:RecordField Name="AVG_USAGE_AMOUNT" />
<ext:RecordField Name="AVG_USAGE_AMOUNT_TOP" />
</Fields>
</ext:JsonReader>
</Reader>
<SortInfo Field="USAGE_AMOUNT" Direction="desc" />
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ColumnID="OPERATE_NAME" Header="手术名称" DataIndex="OPERATE_NAME" Width="" />
<ext:GroupingSummaryColumn ColumnID="OPERATE_NAME" Header="手术名称" DataIndex="OPERATE_NAME"
Hideable="false" SummaryType="Count" Width="">
<SummaryRenderer Handler="return '总计';" />
</ext:GroupingSummaryColumn>
<ext:Column Header="医生" DataIndex="DOCTOR_NAME" Width="" />
<ext:Column Header="所在科室" DataIndex="DEPT_NAME" Width="">
</ext:Column>
<ext:GroupingSummaryColumn ColumnID="LISHU" Header="例数" DataIndex="LISHU" Width=""
SummaryType="Sum">
<SummaryRenderer Handler="return value+' 例';" />
<Renderer Handler="return value+' 例';" />
</ext:GroupingSummaryColumn>
<ext:GroupingSummaryColumn Header="用血量" DataIndex="USAGE_AMOUNT" Width="" SummaryType="Sum">
<SummaryRenderer Handler="return value+' ml';" />
<Renderer Handler="return value+' ml';" />
</ext:GroupingSummaryColumn>
<ext:Column Header="平均值" DataIndex="AVG_USAGE_AMOUNT" Width="" />
<ext:Column Header="排名" DataIndex="AVG_USAGE_AMOUNT_TOP" Width="" />
</Columns>
</ColumnModel>
<LoadMask ShowMask="true" />
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
</SelectionModel>
<View>
<ext:GroupingView ID="GroupingView1" HideGroupedColumn="true" runat="server" ForceFit="true"
StartCollapsed="true" GroupTextTpl='<span id="ColorCode-{[values.rs[0].data.ColorCode]}"></span>{text} ({[values.rs.length]} {[values.rs.length > 1 ? "项" : "项"]})'
EnableRowBody="true">
<Listeners>
<Refresh Fn="setGroupStyle" />
</Listeners>
</ext:GroupingView>
</View>
<Plugins>
<ext:GroupingSummary ID="GroupingSummary1" runat="server">
<Calculations>
<ext:JFunction Name="totalCost" Handler="return v + (record.data.Estimate * record.data.Rate);" />
</Calculations>
</ext:GroupingSummary>
</Plugins>
</ext:GridPanel>
5、GridPanel动态绑定列
/// <summary>
/// 生成字段和列,并绑定数据源
/// </summary>
private void DynamicBindData(DataTable _rptData, GridPanel _gp, Store _store)
{
//清除旧数据与记录集
_store.Reader.Clear();
_gp.SelectionModel.Clear();
_gp.ColumnModel.Columns.Clear();
//_store.Model.Clear();
var _jsonReader = new JsonReader();
foreach (DataColumn _dataColumn in _rptData.Columns)
{
//创建字段
_jsonReader.Fields.Add(new RecordField(_dataColumn.ColumnName));
//创建列
var _column = new Column
{
Header = Server.HtmlEncode(_dataColumn.ColumnName),
DataIndex = _dataColumn.ColumnName,
};
_gp.ColumnModel.Columns.Add(_column);
}
_store.Reader.Add(_jsonReader);
_store.DataSource = _rptData.DefaultView;
_store.DataBind();
// 重绘【必须调用】
_gp.Render();
}
6、后台(.cs)文件常用方法
// GridPanel选中列后台操作
int nCount = ;
RowSelectionModel sm = this.GridPanel1.SelectionModel.Primary as RowSelectionModel;
nCount = sm.SelectedRows.Count;
if (nCount == )
{
X.Msg.Alert("系统提示", "请先选择要删除的记录!").Show();
return;
}
foreach (SelectedRow row in sm.SelectedRows)
{
string selectId = row.RecordID;
// 业务处理...
}