PDA

View Full Version : Get All Data From GridPanel



AbdallahAshour
Jul 30, 2015, 7:18 AM
hii

how i can get all data in gridpanel

in old version of Ext.Net
i Use This Code

(JavaScript)



var function = ViewDate(grid){

var GridViewData = Sys.Serialization.JavaScriptSerializer.serialize(E xt.getCmp(grid.id).getRowsValues());

}




the correct output like this

24101




now i use Ext.net 3.2


but when i use this code Ext.getCmp(grid.id).getRowsValues();

Bring me something wrong

like this


24102


thanks

AbdallahAshour
Aug 13, 2015, 7:40 PM
Any help Plzzzzzzzzzzz

Daniil
Aug 21, 2015, 1:45 PM
Hi @AbdallahAshour,

Please provide a test case to reproduce the problem.

AbdallahAshour
Aug 26, 2015, 1:55 PM
hi mr @Daniil


i have gridpanel contain data
i need to get all data in the gridpanel

i need it in JavaScript
like this




Ext.getCmp(grid.id).getRowsValues()




i have grid panel like this

this is my test case
i have Column (DateColumn) title for that column is (lastChange)

When is don't contain data and i use the function to get data from grid panel i don't see that column (lastChange)


Ext.getCmp(grid.id).getRowsValues()

this my Image

24182

but When that Column Contain Data he get data

like this but not for all

24184


i need now function to get all data in the View (in JavaScript)

Plz Help me

Daniil
Aug 26, 2015, 6:58 PM
Please try SubmitEmptyValue="Null".

<ext:ModelField Name="lastChange" Type="Date" SubmitEmptyValue="Null" />

Then if there is no value, it appears a null in a result of getRowsValues call .

AbdallahAshour
Aug 27, 2015, 9:30 AM
thank you mr.@Daniil

another question how i can get data from grid panel like in view

example:

the data in store:

Money:1000

in the View:
Money:1,000

i want to get data from grid like view

Daniil
Aug 27, 2015, 1:08 PM
Unfortunately, there is no such an option for getRowsValues.

You can go throught the data returned by a .getRowsValues() call and transform as needed.

Also you can try with

Ext.net.GridPrinter.convertData(grid, grid.headerCt.getGridColumns(), {});
and see if it does the job that you need.

AbdallahAshour
Aug 31, 2015, 8:31 AM
thank you @Daniil Very much

yes it work
and that what i need


but i see simple problem

when column name contain (-) like this (Branch-Name)
it give me tow column (Branch-Name) and (BranchName)

24191

Daniil
Sep 07, 2015, 12:15 PM
Reproduced. I investigated why it happens. It might be required for the printing functionality.

Okay, I took Ext.net.GridPrinter.convertData as a base and adjusted it to the requirement.

Example

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

<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[] { "test11", "test21" },
new object[] { "test12", "test22" },
new object[] { "test13", "test23" }
};
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v3 Example</title>

<script>
var getGridPanelData = function (grid, config) {
var data = [],
columns = grid.headerCt.getGridColumns(),
config = config || {};

Ext.each(config.currentPageOnly ? grid.store.getRange() : grid.store.getAllRange(), function (record, index) {
var item = {},
i, len, c, meta, value;

for (i = 0, len = columns.length; i < len; i++) {
c = columns[i];

if (c.dataIndex) {
value = record.data[c.dataIndex];
meta = { tdCls: "", tdAttr: "", style: "" };
value = c.renderer ? c.renderer.call(c, value, meta, record, index, i, grid.store, grid.view) : value;
item[c.dataIndex] = value;
} else if (c.isXType("rownumberer")) {
meta = { tdCls: "", tdAttr: "", style: "" };
item[Ext.String.createVarName(c.id)] = c.renderer.call(c, null, meta, record, index, i, grid.store, grid.view); //index + 1;
} else if (column.isXType("templatecolumn")) {
value = c.tpl ? c.tpl.apply(record.data) : value;
item[Ext.String.createVarName(c.id)] = value;
}
}

item.__internalId = record.internalId;
data.push(item);
});

return data;
};

var onButtonClick = function() {
console.log(getGridPanelData(App.GridPanel1));
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Button runat="server" Text="Get data" Handler="onButtonClick" />

<ext:GridPanel ID="GridPanel1" runat="server">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="test1" />
<ext:ModelField Name="test-2" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test 1" DataIndex="test1" />
<ext:Column runat="server" Text="Test 2" DataIndex="test-2" />
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>

AbdallahAshour
Sep 10, 2015, 7:24 AM
thank you @Daniil Very much

It works as I want