- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
下面,我有一个项目记录网格。我正在通过 asmx 网络服务加载项目记录列表。我通过 json 代理将 .NET 中的 List 对象返回到我的项目列表存储区。每个 Project 对象都绑定(bind)到我的 Project 模型。双击项目列表网格中的一行启动项目编辑表单。
在单击“保存”按钮后,我很难在弹出表单 (widget.projectedit) 中保存对记录的编辑。我不确定我是否应该将我的更新发送到项目存储并将我的存储与我的代理同步,或者为单个项目记录设置单独的存储和代理,然后只刷新我的项目存储和 View 。
正在调用“editProject”来启动我的表单。我想要“updateProject”来更新我的记录,但我还没有它的委托(delegate)(我没有在下面的代码中调用/调用它)。
具体问题:
如何调用“updateProject”函数?
如何更新我的项目列表网格存储?
我需要更改哪些代码? (我可以弄清楚要在 asmx 服务中放入什么代码。我只需要有关 JavaScript 代码的帮助)
项目列表.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ProjectList.ascx.cs" Inherits="Web.Controls.ProjectList.ProjectList" %>
<div id="example-grid"></div>
<asp:ScriptManager ID="PageScriptManager" runat="server">
<Services>
<asp:ServiceReference Path="~/WebService1.asmx" InlineScript="false" />
</Services>
<Scripts>
<asp:ScriptReference Path="~/ext-4/ext-all-debug.js" />
<asp:ScriptReference Path="~/Controls/ProjectList/ProjectList.js" />
<asp:ScriptReference Path="~/Controls/ProjectList/Proxy.js" />
</Scripts>
</asp:ScriptManager>
<script type="text/javascript">
Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.panel.*',
'Ext.layout.container.Border'
]);
Ext.namespace('EXT');
Ext.define('Project', {
extend: 'Ext.data.Model',
fields: [
'project_id',
'project_name',
'project_number'
]
});
Ext.define('ProjectEdit', {
extend: 'Ext.window.Window',
alias: 'widget.projectedit',
title: 'Edit Project',
layout: 'fit',
autoShow: true,
initComponent: function () {
this.items = [
{
xtype: 'form',
items: [
{
xtype: 'textfield',
name: 'project_id',
fieldLabel: 'Project ID'
},
{
xtype: 'textfield',
name: 'project_number',
fieldLabel: 'Project Number'
},
{
xtype: 'textfield',
name: 'project_name',
fieldLabel: 'Project Name'
}
]
}
];
this.buttons = [
{
text: 'Save',
action: 'save'
},
{
text: 'Cancel',
scope: this,
handler: this.close
}
];
this.callParent(arguments);
}
});
var store = new Ext.data.Store(
{
proxy: new Ext.ux.AspWebAjaxProxy({
url: 'http://localhost/WebService1.asmx/GetProjects',
actionMethods: {
create: 'POST',
destroy: 'DELETE',
read: 'POST',
update: 'POST'
},
extraParams: {
myTest: 'a',
bar: 'foo'
},
reader: {
type: 'json',
model: 'Project',
root: 'd'
},
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
})
});
Ext.define('ProjectGrid', {
extend: 'Ext.grid.Panel',
initComponent: function () {
var me = this;
Ext.applyIf(me, {
store: store,
columns: [
{ text: 'Project ID', width: 180, dataIndex: 'project_id', sortable: true },
{ text: 'Project Number', width: 180, dataIndex: 'project_number', sortable: true },
{ text: 'Project Name', width: 180, dataIndex: 'project_name', sortable: true }
],
listeners: {
itemdblclick: this.editProject
}
});
me.callParent(arguments);
},
editProject: function (grid, record) {
var view = Ext.widget('projectedit');
view.down('form').loadRecord(record);
},
updateProject: function (button) {
var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();
record.set(values);
win.close();
// synchronize the store after editing the record
this.getProjectStore().sync();
}
});
// create the grid
var grid = Ext.create('ProjectGrid', {
title: 'Project List',
renderTo: 'example-grid',
width: 540,
height: 200
});
store.load();
</script>
网络服务:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Xml;
using System.Data;
using System.Web.Script.Services;
using System.IO;
using System.Text;
namespace Web
{
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
public class Project
{
public string project_id;
public string project_number;
public string project_name;
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json,
UseHttpGet = false, XmlSerializeString = false)]
public List<Project> GetProjects(string myTest, string bar)
{
var list = new List<Project>(new[] {
new Project() {project_id="1", project_name="project 1", project_number="001"},
new Project() {project_id="2", project_name= "project 2", project_number= "002" },
new Project() {project_id="3", project_name= "project 3", project_number= "003" }
});
return list;
}
}
}
最佳答案
你需要决定:
ONE:在编辑器窗口中独立加载和保存模型。
示例代码:http://jsfiddle.net/el_chief/rUaV3/4/
(上面的 ajax 保存是假的,所以你不会在网格上看到更新)。
二:从调用者传入模型,并将模型保存在调用者中。
示例代码:http://jsfiddle.net/el_chief/5jjBS/4/
ONE 有点慢,但一切都是独立的,你也可以独立测试它们。-
此外,如果您从调用方传入模型并且用户进行更改然后关闭子窗口,则这些更改可能会出现在调用方中(取决于您如何进行 View /模型同步)。
另外,通常情况下,您只想抓取几个字段显示在网格上,但在项目 View 表单上显示所有字段。在这种情况下,您需要选项 ONE。
无论哪种方式,您都应该将回调函数传递给子窗口,它会在“完成”时调用。这样您就可以从子窗口取回所需的任何数据,并在需要时将其关闭。
您也不需要单独为橱窗设计商店。你应该把你的代理放在你的模型上(商店使用它的模型代理,你总是可以覆盖它)
保存的一个关键方面是您需要返回一些数据,通常是完整的记录,例如:
{
success:true,
contacts:[
{
id:1,
name:'neil mcguigan updated record'
}
]
}
关于.net - ExtJS 4 : Saving record in record edit form to server and update grid store,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11573098/
我一直在尝试将 Redux 集成到项目中。 我按照使用示例进行操作,但收到错误store.getState is not a function。 所以我知道其他人也问过类似的问题,但情况略有不同。 R
我正在尝试将我的第一个应用程序上传到 App Store。我已完成 iTunes Connect 所需的所有步骤,我的应用程序状态为“等待上传”。 我相信下一步是使用 Application Load
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭10 年前。 Improve th
App Store 有所谓的“服务器到服务器”通知。也就是说,当您购买应用内功能时,Apple 服务器会向您服务器的回调方法(发送收据数据)发出 HTTPS 请求。 问题是 - 收据数据中似乎没有用户
我已经将我的第一个应用程序上载到App Store,但是我没有放置我的App需要位置服务和wifi的UIRequiredDeviceCapabilities。结果:该应用程序没有像应做的那样开始寻找坐
由于iOS 8将于本月发布,并且我的应用仅支持32位(因为第3个库仅兼容32位),因此我不确定如果我将新版本的应用提交给我,则该应用的新版本是否会被拒绝App Store将于下个月发布,因为它不支持6
我有一个让我有些困惑的问题。 为了将我的应用提交到App Store,我必须输入Bundle ID后缀。如您所知,Bundle ID会获得Bundle ID后缀的确切名称(您在Bundle ID后缀上
如问题所述,我想知道更新后的应用程序一旦获得批准,是否会自动发布到应用程序商店中? 我的更新已完成并且已经过测试,由于需要几天的时间才能批准,因此我希望现在将其提交批准。同时,我需要在服务器上更改一些
获取应用程序提交到 Apple App Store 的屏幕截图的最简单方法是什么,需要包含的各种尺寸是多少? 另外,是否允许状态栏?我相信我听说它不是,但是包括 Facebook 和 Quora 在内
我在 iTunes 商店中有一个应用程序,其分发证书(在 key 链访问中)将于明天到期。它是一年前生成的,尽管我最近更新了我的 iPhone 开发者计划,但我还没有更新任何证书或签名。 当我将测试设
我的商店包含以下 reducer : export const centralStampState = { layoutState : layoutReducer, //this one is n
我即将将我的应用程序提交到 Apple App Store,并且我了解到 Apple 需要两周时间才能对其进行审核,然后才能上线。但是,在 iTunes Connect 的定价部分,它询问我什么时候发
如果我的应用程序正在接受审核或已获得批准(因此处于 Ready For Sale 状态或同等状态),我可以编辑哪些应用程序信息而无需提交应用程序的新版本? 最佳答案 据此Apple Documenta
我已经在Opera管理控制台上进行了全面检查,看不到他们在哪里提到付款方式。他们说明何时制作,但没有说明。即Paypal,Cheque等。 有人知道他们如何付款吗? 最佳答案 当金额达到200美元时,
我上传了我的二进制文件并创建了屏幕截图。我做的所有屏幕截图都是 640x960,我将它们上传为 PNG。这背后的想法是,我应该以尽可能最好的质量把它交给他们,这样当他们将它们重新压缩成 320x480
我从Microsoft下载了Windows 8 app samples,并下载了这些示例之一加速度传感器示例 我不知道如何测试它以计划使用此功能的软件? 我没有水面设备,想知道只有一种方法可以做到吗?
我正在为TestFlight上传第二个应用程序。第一次进展顺利,但这次却被拒绝了。 We have started the review of your beta app, but we are no
不确定这是正确的论坛,如果不是,我提前道歉。 某处是否有 App Store 新版本的提要?还是带有类别和发布日期的应用提要/列表? 此列表已从 App Store 中消失,我想看看是否可以制作一个应
我有一个 JSON 存储,定义如下 var subAccountStore = new Ext.data.JsonStore({ autoLoad: true, proxy: { ty
我有一个提交到应用商店的应用被拒绝,原因是: 2.30 不符合 Mac OS X 文件系统文档的应用将被拒绝 他们声称我的应用正在修改不受支持的 ~/Library/Preferences/com.a
我是一名优秀的程序员,十分优秀!