在之前已讲述TreePanel与GridPanel之间的联动,如果GridPanel在不同的标签中,又如何定位到标签中的GridPanel的某一行呢,这是本篇需要讲述的内容:以下做为一个例子:
三个标签,分别为:TabClientJobs、TabCorporate、TabFreelance
代码
<ext:TreePanel ID="ClientJobTree" runat="server" Icon="Note" Border="false"
AutoScroll="true">
<Listeners>
<Click Handler="selectGridPanelbyNodeID(node.id,#{TabPanelClientJob});" />
</Listeners>
</ext:TreePanel>
脚本代码:
代码
function selectGridPanelbyNodeID(id, tabPanel) {
//获取类型(即标签)
var type = Coolite.AjaxMethods.GetType(id, { success: function(result) {
switch (result) {
case "0":
{
//切换标签
tabPanel.setActiveTab(Ext.getCmp("<%= TabClientJobs.ClientID %>"));
//获取GridPanel
var grid = Ext.getCmp("<%= GridPanelCustomer.ClientID %>");
//通过ID查找信息
var record = grid.store.getById(id);
//选中该行
grid.getSelectionModel().selectRow(grid.store.indexOf(record));
break;
}
case "1":
{
tabPanel.setActiveTab(Ext.getCmp("<%= TabCorporate.ClientID %>"));
var grid = Ext.getCmp("<%= GridPanelCorporate.ClientID %>");
var record = grid.store.getById(id);
grid.getSelectionModel().selectRow(grid.store.indexOf(record));
break;
}
case "2":
{
tabPanel.setActiveTab(Ext.getCmp("<%= TabFreelance.ClientID %>"));
var grid = Ext.getCmp("<%= GridPanelFreelance.ClientID %>");
var record = grid.store.getById(id);
grid.getSelectionModel().selectRow(grid.store.indexOf(record));
break;
}
}
}
});
}