PDA

View Full Version : [CLOSED] gridPanel enable nullable<double>



marco.morreale
May 16, 2014, 11:07 AM
hi,
i have a gridpanel with store like



.Store(
Html.X().StoreForModel().Control(s =>
{
s.AutoSync = true;
s.Proxy.Add(
new RestProxy
{
AppendAction = false,
Reader = {
new JsonReader {
Root = "data",
MessageProperty = "message"
}
},
API =
{
Read = Url.Action("Read"),
Update = Url.Action("Update"),
Create = Url.Action("Create"),
Destroy = Url.Action("Destroy")
},
Writer = {
new JsonWriter
{
AllowSingle = true
}
}
}
);
s.Listeners.Write.Fn = "onWrite";
})
.PageSize(3)
.ID("Store1")
)


in my model i have same property nullable<double> like



public double? dec
{
get;
set;
}


the columns in a view are like



Html.X().ColumnFor(Model, m => m.dec)
.ToBuilder<Column.Builder>()
.Flex(1)
.Editor(Html.X().NumberField().DecimalPrecision(1) .Step(0.1).MinValue(-100).MaxValue(100).AllowBlank(true))
.Renderer(RendererFormat.Number, new string[] { "'0.000/i'" })
.SummaryRenderer(new Renderer() { Fn = "Ext.util.Format.numberRenderer('0.000/i')" })
.SummaryType(SummaryType.Sum)


I have two problem:

1. if dec is null in grid appare 0 I want to see empty cell
2. if I update dec column with empty cell in my controller i receive 0 but I want to receive null value

my update method in control is



[AcceptVerbs(HttpVerbs.Put)]
public RestResult Update(TestPerson dato)
{
return new RestResult
{
Success = true,
Message = "Il dato ? stato aggiornato",
Data = dato
};
}



Thanks in advance
Marco

Daniil
May 16, 2014, 12:59 PM
1. if dec is null in grid appare 0 I want to see empty cell


Please use UseNull.

[ModelField(UseNull = true)]
public double? dec
{
get;
set;
}
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Field-cfg-useNull



2. if I update dec column with empty cell in my controller i receive 0 but I want to receive null value


I think it should be OK now with the "UseNull = true" setting.

marco.morreale
May 22, 2014, 12:17 PM
Perfect it work well.
Thanks Daniil