May 12, 2009, 10:09 AM
[CLOSED] grid row focus
hi,
i have manually move the 10th page of the grid and focus the second record of the gridpanel. but the code is not working. plz check my code.
i have manually move the 10th page of the grid and focus the second record of the gridpanel. but the code is not working. plz check my code.
<%@ Page Language="C#" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script runat="server">
protected void MaskClick1(object sender, AjaxEventArgs e)
{
// page number = getIntValue((position number)/(page size))+1 - it is formula only, not code
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.Add("POS_VALUE", typeof(string));
dt.Columns.Add("POS_DESCR", typeof(string));
System.Data.DataRow DrNew = null;
for (int i = 0; i < 500; i++)
{
DrNew = dt.NewRow();
DrNew[0] = i;
DrNew[1] = "Test";
dt.Rows.Add(DrNew);
dt.AcceptChanges();
}
Sto4.DataSource = dt;
Sto4.DataBind();
}
protected void MaskClick(object sender, AjaxEventArgs e)
{
//int number = Convert.ToInt32(55/25)+1 ;
PagingToolBar2.PageIndex = 10;
RowSelectionModel sm = this.GrdPnl1.SelectionModel.Primary as RowSelectionModel;
sm.SelectedRows.Add(new SelectedRow(1));
sm.UpdateSelection();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" RenderStyles="File">
</ext:ScriptManager>
<ext:Store ID="Sto4" runat="server">
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name="POS_VALUE"></ext:RecordField>
<ext:RecordField Name="POS_DESCR"></ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:Button ID="Button2" runat="server" Text="Bind Record">
<AjaxEvents>
<Click OnEvent="MaskClick1" >
</Click>
</AjaxEvents>
</ext:Button>
<ext:Button ID="Button1" runat="server" Text="Focus row">
<AjaxEvents>
<Click OnEvent="MaskClick">
</Click>
</AjaxEvents>
</ext:Button>
<ext:GridPanel
ID="GrdPnl1"
runat="server"
AutoHeight="true"
StoreID="Sto4"
>
<ColumnModel>
<Columns>
<ext:Column DataIndex="POS_VALUE" Width="50" Header="COLOUMN1" />
<ext:Column DataIndex="POS_DESCR" Width="100" Header="COLOUMN2" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
</SelectionModel>
<BottomBar>
<ext:PagingToolBar ID="PagingToolBar2" runat="server" PageSize="20" StoreID="Sto4" DisplayInfo="true" />
</BottomBar>
</ext:GridPanel>
</form>
</body>
</html>