I'm using dojo 1.6 and I wanna create a store to connect to a grid; however, in dojo 1.6 only exists two ways with ItemFileWriteStore and store Memory which of these two is the best ?
I'm working with spring 2.5 for the controller.
I'm using dojo 1.6 and I wanna create a store to connect to a grid; however, in dojo 1.6 only exists two ways with ItemFileWriteStore and store Memory which of these two is the best ?
I'm working with spring 2.5 for the controller.
不一定有一个“正确”的答案,但这里有一些事情需要考虑。
该dojo/store
API 旨在成为下一步,取代dojo/data
. 因此,dojo/store
从最佳/现代实践的角度推荐。
但是,假设您正在谈论dojox/grid
,该组件只知道如何消费dojo/data
商店。这让您有两个选择:
dojo/data/ItemFileWriteStore
dojo/store/Memory
Wrapped in dojo/data/ObjectStore
(它dojo/store
用dojo/data
API 包装 a,以便旧商店的消费者可以使用它)另一件值得考虑的事情是它dojo/store/Memory
不支持直接从 URL 中提取数据,而支持dojo/data/ItemFileWriteStore
。如果您打算从另一个 URL 加载数据,您仍然可以使用dojo/store/Memory
,但您必须先自己 XHR 数据。
主要感谢一个把xhr的论点
var xhrArgsSolEnv = {
url : "BandejaDrawback.htm?action=conSolPrelim",
handleAs : "json"
};
then i invoke the function
var cargarSolicEnv = dojo.xhrGet(xhrArgsSolEnv);
var xhrArgsSolEnv = {
url : "BandejaDrawback.htm?action=conSolPrelim",
handleAs : "json"
};
and populate the grid
function js_solicitudEnv(data){
var mydata = new dojo.store.Memory({data : data});
var store = new dojo.data.ObjectStore({objectStore: mydata});
var layoutSolEnv = [{ name : "Orden", field : "orden",width : "10%",styles: "text-align: center;" },
{ name : "Solicitud", field : "numSolicitud",width :"15%" , styles: "text-align: center;"
,formatter: function(value){return "<a href='#'>"+value+"</a>";}},
{ name : "Fecha de Registro" ,field: "fecRegistro", width :"25%",styles: "text-align: center;"},
{ name : "Monto", field: "mtoSolicitado", width :"20%",styles: "text-align: center;"},
{ name : "Estado", field: "estado", width :"30%",styles: "text-align: center;"}];
var gridSolicEnv = new dojox.grid.DataGrid({
store : store,
structure : layoutSolEnv,
style : "width : 800px; height : 150px"
},"gridSolicEnv");
gridSolicEnv.startup();
var btnNuevaSol = new dijit.form.Button({
showlabel : true,
label : "Nueva Solicitud",
onClick : function(){
window.location.href = "BandejaDrawback.htm?action=valAccRegistrodeSolicitud";
}
},"btnNuevaSol");
if(data.totalCount >=5){
btnNuevaSol.set("disabled",true);
}
}