PDA

View Full Version : [CLOSED] getById is not working



enavarrete
Oct 09, 2014, 5:54 PM
Hi! i?ve been triyng to get some data from a store, but it keeps returning null.

this is what i have in codeBehind:


Dim ccSituacionPre As New Column With {.ID = "SituacionPreliquidacion", .DataIndex = "SituacionPreliquidacion", .Text = "Situaci?n Preliquidaci?n", .ToolTip = "Situaci?n Preliquidaci?n", .MenuDisabled = True, .Flex = 1}
Dim cmbCcSituacionPre As New ComboBox
With cmbCcSituacionPre
.ID = "cmbCcSituacionPre"
.StoreID = sSituacionesRepartoPre.ID
.ValueField = "IDSituacion"
.DisplayField = "Descripcion"
.TypeAhead = True
.SelectOnTab = True
End With
Dim mdlPre As New Model
mdlPre.Fields.Add(New ModelField With {.Name = "IDSituacion", .ModelName = "IDSituacion"})
mdlPre.Fields.Add(New ModelField With {.Name = "Descripcion", .ModelName = "Descripcion"})
sSituacionesRepartoPre.Model.Add(mdlPre)

ccSituacionPre.Renderer.Fn = "rndPreliquidacion"
ccSituacionPre.Editor.Add(cmbCcSituacionPre)

And this what i have in a js:


var rndPreliquidacion = function (value) {
var r = App.sSituacionesRepartoPre;
if (Ext.isEmpty(r) || Ext.isEmpty(value)) {
return "";
}
var txt = r.getById(value);
return txt;

};

But it always returns null;

Daniil
Oct 09, 2014, 6:24 PM
Hi @enavarrete,

Welcome to the Ext.NET forums!

There might be a few reasons. For example, the types mismatch. The "value" is a string, but the records' ids are int type. It is a common mistake in such cases. Though, there might be other reasons.

To get rid of guesswork, could you, please, provide a full test case to reproduce? I think we could help very fast after that.

By the way, you should not return a record instance from a Renderer. It should be a string.

enavarrete
Oct 09, 2014, 7:31 PM
Thanks a lot, maybe the whole Method works for the test. And By the way, you are right about the return a string, it?s just i?ve made so many changes.

this is the whole method:


Private Function FncSituacionReparto() As GridPanel
Dim gdSituacion As New GridPanel
With gdSituacion
.ID = "gdSituacion"
.Layout = "Fit"
.Title = "Situaci?n de Reparto"
.Region = Region.Center
.Flex = 3
.BodyPadding = 6
.StoreID = sCapturaSituacionReparto.ID
End With

Dim mdlCapturaSituacionReparto As New Model
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "AnioProceso", .ModelName = "AnioProceso"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "CampaniaProceso", .ModelName = "CampaniaProceso"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "IdZona", .ModelName = "IdZona"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "NumeroPorteador", .ModelName = "NumeroPorteador"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "Dama", .ModelName = "Dama"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "NumeroPedido", .ModelName = "NumeroPedido"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "NumeroCamioneta", .ModelName = "NumeroCamioneta"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "NumeroPosicion", .ModelName = "NumeroPosicion"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "NumeroPreliquidacion", .ModelName = "NumeroPreliquidacion"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "SituacionPreliquidacion", .ModelName = "SituacionPreliquidacion"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "DescripcionPre", .ModelName = "DescripcionPre"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "DescripcionCierre", .ModelName = "DescripcionCierre"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "SituacionCierre", .ModelName = "SituacionCierre"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "ImporteEntregar", .ModelName = "ImporteEntregar"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "ImporteRecuperar", .ModelName = "ImporteRecuperar"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "CapImporteEfectivo", .ModelName = "CapImporteEfectivo"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "CapImporteFI", .ModelName = "CapImporteFI"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "CapImporteNotaCredito", .ModelName = "CapImporteNotaCredito"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "CapImporteReciboCobranza", .ModelName = "CapImporteReciboCobranza"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "CapFolioReciboCobranza", .ModelName = "CapFolioReciboCobranza"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "CapTipoRecibo", .ModelName = "CapTipoRecibo"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "CapImporteCancelado", .ModelName = "CapImporteCancelado"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "CapImporteAnticipo", .ModelName = "CapImporteAnticipo"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "CapImporteSaldo", .ModelName = "CapImporteSaldo"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "EstatusCaptura", .ModelName = "EstatusCaptura"})
mdlCapturaSituacionReparto.Fields.Add(New ModelField With {.Name = "EstatusRegistro", .ModelName = "EstatusRegistro"})

sCapturaSituacionReparto.Model.Add(mdlCapturaSitua cionReparto)



Dim ccSituacionPre As New Column With {.ID = "SituacionPreliquidacion", .DataIndex = "SituacionPreliquidacion", .Text = "Situaci?n Preliquidaci?n", .ToolTip = "Situaci?n Preliquidaci?n", .MenuDisabled = True, .Flex = 1}
Dim cmbCcSituacionPre As New ComboBox
With cmbCcSituacionPre
.ID = "cmbCcSituacionPre"
.StoreID = sSituacionesRepartoPre.ID
.ValueField = "IDSituacion"
.DisplayField = "Descripcion"
.TypeAhead = True
.SelectOnTab = True
End With
Dim mdlPre As New Model
mdlPre.Fields.Add(New ModelField With {.Name = "IDSituacion", .ModelName = "IDSituacion"})
mdlPre.Fields.Add(New ModelField With {.Name = "Descripcion", .ModelName = "Descripcion"})
sSituacionesRepartoPre.Model.Add(mdlPre)

ccSituacionPre.Renderer.Fn = "rndPreliquidacion"
ccSituacionPre.Editor.Add(cmbCcSituacionPre)

Dim ccSituacionCierre As New Column With {.ID = "SituacionCierre", .Hidden = True, .DataIndex = "SituacionCierre", .Text = "Situaci?n Cierre", .ToolTip = "Situaci?n Cierre", .MenuDisabled = True, .Flex = 1}
Dim cmbCcSituacionCierre As New ComboBox
With cmbCcSituacionCierre
.StoreID = sSituacionesRepartoCierre.ID
.ValueField = "IDSituacion"
.DisplayField = "Descripcion"
.TypeAhead = True
.SelectOnTab = True
End With
Dim mdlCierre As New Model
mdlCierre.Fields.Add(New ModelField With {.Name = "IDSituacion", .ModelName = "IDSituacion"})
mdlCierre.Fields.Add(New ModelField With {.Name = "Descripcion", .ModelName = "Descripcion"})
sSituacionesRepartoCierre.Model.Add(mdlCierre)

ccSituacionCierre.Renderer.Fn = "rndCierre"
ccSituacionCierre.Editor.Add(cmbCcSituacionCierre)

Dim iccDama As New ImageCommandColumn With {.ID = "IconoDama", .DataIndex = "Dama", .Text = "", .ToolTip = "Ver Informaci?n de Dama", .Width = 30, .MenuDisabled = True}
iccDama.Commands.Add(New ImageCommand With {.Icon = Icon.UserFemale, .CommandName = "VerDama", .Text = ""})
iccDama.Listeners.Command.Handler = "md.MuestraInfoDama(record.data.Dama);"



gdSituacion.ColumnModel.Columns.Add(New RowNumbererColumn With {.Width = 40})
gdSituacion.ColumnModel.Columns.Add(New Column With {.ID = "NumeroPedido", .DataIndex = "NumeroPedido", .Text = "Pedido", .ToolTip = "N?mero Pedido", .Width = 60, .MenuDisabled = True})
gdSituacion.ColumnModel.Columns.Add(iccDama)
gdSituacion.ColumnModel.Columns.Add(New Column With {.ID = "Dama", .DataIndex = "Dama", .Text = "Dama", .ToolTip = "Dama", .Width = 80, .MenuDisabled = True})
gdSituacion.ColumnModel.Columns.Add(New Column With {.ID = "NumeroPreliquidacion", .DataIndex = "NumeroPreliquidacion", .Text = "Preliq", .ToolTip = "N?mero Preliquidaci?n", .Width = 60, .MenuDisabled = True})
gdSituacion.ColumnModel.Columns.Add(ccSituacionPre )
gdSituacion.ColumnModel.Columns.Add(New Column With {.ID = "Prueba", .Text = "Prueba"})
gdSituacion.ColumnModel.Columns.Add(New Column With {.ID = "ImporteEntregar", .DataIndex = "ImporteEntregar", .Text = "Imp Entr", .ToolTip = "Importe a Entregar", .Width = 70, .MenuDisabled = True})
gdSituacion.ColumnModel.Columns.Add(New Column With {.ID = "ImporteRecuperar", .DataIndex = "ImporteRecuperar", .Text = "Imp Recup", .ToolTip = "Importe a Recuperar", .Width = 80, .MenuDisabled = True})
gdSituacion.ColumnModel.Columns.Add(New Column With {.ID = "CapImporteEfectivo", .DataIndex = "CapImporteEfectivo", .Text = "Efectivo", .ToolTip = "Importe en Efectivo", .Width = 70, .MenuDisabled = True})
gdSituacion.ColumnModel.Columns.Add(New Column With {.ID = "CapImporteFI", .DataIndex = "CapImporteFI", .Text = "FI", .ToolTip = "Importe en Fichas Individuales", .Width = 70, .MenuDisabled = True})
gdSituacion.ColumnModel.Columns.Add(New Column With {.ID = "CapImporteNotaCredito", .DataIndex = "CapImporteNotaCredito", .Text = "Nota Cr?d", .ToolTip = "Importe en Nota de Cr?dito", .Width = 80, .MenuDisabled = True})
gdSituacion.ColumnModel.Columns.Add(New Column With {.ID = "CapImporteReciboCobranza", .DataIndex = "CapImporteReciboCobranza", .Text = "Rec Cza", .ToolTip = "Importe en Recibo de Cobranza", .Width = 80, .MenuDisabled = True})
gdSituacion.ColumnModel.Columns.Add(New Column With {.ID = "CapFolioReciboCobranza", .DataIndex = "CapFolioReciboCobranza", .Text = "Fol Rec Cza", .ToolTip = "Folio Recibo de Cobranza", .Width = 88, .MenuDisabled = True})
gdSituacion.ColumnModel.Columns.Add(New Column With {.ID = "CapImporteCancelado", .DataIndex = "CapImporteCancelado", .Text = "Cancelado", .ToolTip = "Importe Cancelado", .Width = 80, .MenuDisabled = True})
gdSituacion.ColumnModel.Columns.Add(New Column With {.ID = "CapImporteAnticipo", .DataIndex = "CapImporteAnticipo", .Text = "Anticipo", .ToolTip = "Importe Anticipo", .Width = 70, .MenuDisabled = True})
gdSituacion.ColumnModel.Columns.Add(New Column With {.ID = "CapImporteSaldo", .DataIndex = "CapImporteSaldo", .Text = "Saldo", .ToolTip = "Importe Saldo", .Width = 70, .MenuDisabled = True})

Dim pgEditar As New CellEditing With {.ClicksToEdit = 1}
pgEditar.Listeners.Edit.Fn = "editar"
gdSituacion.Plugins.Add(pgEditar)



Return gdSituacion
End Function



And this is the js, just how in the example is:


var rndPreliquidacion = function (value) {

var r = App.sSituacionesRepartoPre.getById(value);

if (Ext.isEmpty(r)) {
return "";
}
return r.data.Descripcion;
};

Daniil
Oct 10, 2014, 1:53 PM
So, does the problem persist? If so, please provide a full and runnable test case. Please see Example (Very Helpful) here:
Forum Guidelines For Posting New Topics (http://forums.ext.net/showthread.php?3440)