Jan 10, 2011, 4:56 PM
[CLOSED] getRowsValues and getRecordsValues always return id column even when visibleOnly = true
Hello,
The store.getRecordsValues( { visibleOnly: true, grid: gridPanel }) and gridPanel.getRowsValues( { visibleOnly: true }) always shows the id column, even if it is not visible.
Steps to reproduce (using sample code further below):
1) Hide a column
2) Press one of the buttons to get the values
3) Look in firebug console for the values retrieved
4) Note that the column that was hidden as step 1) is correctly not returned
5) Note that the internal id column is returned.
Why this is a problem for me:
I am using this to export date to excel/csv etc, and don't want the internal id column showing up.
Code:
Once I've got the data, I could loop through each row and remove the internal id column, but it would be nice if the getRecordsValues() and getRowsValues() does this instead.
The store.getRecordsValues( { visibleOnly: true, grid: gridPanel }) and gridPanel.getRowsValues( { visibleOnly: true }) always shows the id column, even if it is not visible.
Steps to reproduce (using sample code further below):
1) Hide a column
2) Press one of the buttons to get the values
3) Look in firebug console for the values retrieved
4) Note that the column that was hidden as step 1) is correctly not returned
5) Note that the internal id column is returned.
Why this is a problem for me:
I am using this to export date to excel/csv etc, and don't want the internal id column showing up.
Code:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Collections.Generic" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
var data = new List<object>();
for (int i = 0; i < 20; i++)
{
data.Add(new{ _internalId=i, Name="Rec "+i, Column1=i.ToString(), Column2=i.ToString()});
}
Store1.DataSource = data;
Store1.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="HtmlForm" runat="server">
<div>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Store ID="Store1" runat="server">
<Reader>
<ext:JsonReader IDProperty="_internalId">
<Fields>
<ext:RecordField Name="Name" />
<ext:RecordField Name="Column1" />
<ext:RecordField Name="Column2" />
<ext:RecordField Name="_internalId" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:GridPanel
ID="GridPanel1"
runat="server"
StoreID="Store1"
Width="500"
Height="400"
Title="Hide a column and press one of the buttons">
<ColumnModel>
<Columns>
<ext:Column Header="Record Name" DataIndex="Name" />
<ext:Column Header="Column 1" DataIndex="Column1" />
<ext:Column Header="Column 2" DataIndex="Column2" />
</Columns>
</ColumnModel>
<TopBar>
<ext:Toolbar ID="Toolbar" runat="server">
<Items>
<ext:Button ID="GetRows" runat="server" Text="getRecordsValues (view in firebug console)">
<Listeners>
<Click Handler="console.log(#{Store1}.getRecordsValues({visibleOnly:true, grid:#{GridPanel1}}));" />
</Listeners>
</ext:Button>
<ext:Button ID="Button1" runat="server" Text="getRowsValues (view in firebug console)">
<Listeners>
<Click Handler="console.log(#{GridPanel1}.getRowsValues({visibleOnly:true}));" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:GridPanel>
</div>
</form>
</body>
</html>
WorkaroundOnce I've got the data, I could loop through each row and remove the internal id column, but it would be nice if the getRecordsValues() and getRowsValues() does this instead.
Last edited by Daniil; Jan 11, 2011 at 4:45 PM.
Reason: [CLOSED]