Sep 12, 2013, 11:00 AM
[CLOSED] howto address store when reading a record from store by javascript?
Hi
I had the DirectMethod working perfectly when I added it to a change listener on the paging toolbar. The same DirectMethod isn't working when adding it to a click listener on a button. Do I address the store wrong from outside the context or is this a security issue? Thank you very much.
test.aspx.cs
I had the DirectMethod working perfectly when I added it to a change listener on the paging toolbar. The same DirectMethod isn't working when adding it to a click listener on a button. Do I address the store wrong from outside the context or is this a security issue? Thank you very much.
test.aspx.cs
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
}
}
protected void loadTab(object sender, DirectEventArgs e)
{
// create demo datatable
DataTable dt = new DataTable();
DataColumn dc = new DataColumn("ID");
dt.Columns.Add(dc);
dc = new DataColumn("VALUE");
dt.Columns.Add(dc);
dc = new DataColumn("HIDDEN");
dt.Columns.Add(dc);
DataRow dr = dt.NewRow();
dr["ID"] = "1";
dr["VALUE"] = "One";
dr["HIDDEN"] = "hidden 1";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["ID"] = "2";
dr["VALUE"] = "Two";
dr["HIDDEN"] = "hidden 2";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["ID"] = "3";
dr["VALUE"] = "Three";
dr["HIDDEN"] = "hidden 2";
dt.Rows.Add(dr);
// Build JOb Panel, add items and insert data
Ext.Net.Panel panel = new Ext.Net.Panel
{
Title = "Panel",
ID = "pnlPANEL",
Height = 600,
StyleSpec = "marginTop:10px",
Items =
{
new Ext.Net.DataView {
ID = "dv",
Padding = 5,
ItemSelector = "div",
DisableSelection = true,
Store = {
new Ext.Net.Store {
ID = "STORE_dv", PageSize = 1,
Model = {
new Ext.Net.Model {
Fields = {
new Ext.Net.ModelField { Name = "ID", Type = Ext.Net.ModelFieldType.String },
new Ext.Net.ModelField { Name = "VALUE", Type = Ext.Net.ModelFieldType.String },
new Ext.Net.ModelField { Name = "HIDDEN", Type = Ext.Net.ModelFieldType.String }
},
IDProperty = "ID"
}
},
DataSource = dt,
Sorters = { new Ext.Net.DataSorter { Property = "VALUE", Direction = Ext.Net.SortDirection.DESC } }
}
},
Tpl = new XTemplate {
Html = @"<tpl for=""."">
<div>{ID}<br />{VALUE}
</div>
</tpl>"
}
}
},
BottomBar = {
new PagingToolbar {
HideRefresh = true,
StoreID = "STORE_dv",
DisplayMsg = ""
}
}
};
panel.AddTo(this.PANEL);
panel = new Ext.Net.Panel
{
Layout = "HBoxLayout",
Border = false,
Items = { new Ext.Net.Button { Text = "Click me!", OnClientClick = "App.direct.onClick(#{STORE_dv}.getAt(0).get('ID'));" } }
};
panel.AddTo(this.PANEL);
}
// On Change
[DirectMethod]
public void onClick(string ID)
{
X.Msg.Alert("Demo", ID).Show();
}
}
test.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form" runat="server">
<ext:ResourceManager ID="ResourceManager" runat="server" />
<!-- TAB DETAILS -->
<ext:TabPanel runat="server" ID="TAB" MinTabWidth="100">
<Items>
<ext:Panel ID="PANEL" runat="server" Title="Panel"><DirectEvents><Activate OnEvent="loadTab" /></DirectEvents></ext:Panel>
</Items>
</ext:TabPanel>
</form>
</body>
</html>
Last edited by Daniil; Sep 13, 2013 at 4:38 PM.
Reason: [CLOSED]