PDA

View Full Version : [CLOSED] Add record in Store?



aditya
Feb 06, 2014, 6:56 AM
Hi,
I am inserting record in store. New record added 0 in int type column grid panel ext.net? how to get rid of this? i want to no value in that place?
thank in advance

Daniil
Feb 06, 2014, 8:30 AM
Hi @aditya,

Probably, there is a ModelField with Type="Int", isn't? "0" is a value by default.

Please provide a test case, I will try to find a solution for you.

aditya
Feb 11, 2014, 7:21 AM
Hi @aditya,

Probably, there is a ModelField with Type="Int", isn't? "0" is a value by default.

Please provide a test case, I will try to find a solution for you.

Yes 0 is default value for model field of type "Int". I would like to display nothing here. How to display nothing in place of '0'? Thanks in advance.

Daniil
Feb 11, 2014, 1:17 PM
I think a ModelField's UseNull="true" setting is for you.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Field-cfg-useNull

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.GridPanel1.GetStore();
store.DataSource = new object[]
{
new object[] { 1 },
new object[] { 2 },
new object[] { 3 }
};
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Button runat="server" Text="Add" Handler="App.GridPanel1.store.add({});" />

<ext:GridPanel ID="GridPanel1" runat="server">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="number" Type="Int" UseNull="true" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Number" DataIndex="number" />
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>