PDA

View Full Version : [CLOSED] PageProxy in GridPanel issue



multimediait
Apr 01, 2014, 10:28 AM
Good morning, I've this gridpanel:



/*
* Evento eseguito quando una griglia viene associata ad uno store, cambiamento pagina e refresh
* - store: Store da associare alla griglia
*/
var onRefreshGrid = function (store) {
/* Recupera il seriale dell'archivio e il numero di pagina corrente */
var serial = store.storeId.split('_')[2];
var p = store.currentPage;
/* Associo uno store alla griglia */
App.direct.BindArchive(serial, p);
};




<ext:GridPanel ID="gridRecord"
runat="server"
Header="False"
ForceFit="True"
AllowDeselect="True">
<Store>
<ext:Store ID="store"
runat="server"
AutoLoad="True"
RemoteSort="True"
RemotePaging="True">
<Model>
<ext:Model runat="server" IDProperty="SYS_RECORD" />
</Model>

<Proxy>
<ext:PageProxy/>
</Proxy>

<Listeners>
<Refresh Handler="onRefreshGrid(store)" />
<Load Handler="getViewBySerial(getSerial()).show()" />
</Listeners>
</ext:Store>
</Store>
<SelectionModel>
<ext:RowSelectionModel runat="server" Mode="Multi" AllowDeselect="True" />
</SelectionModel>
<TopBar>
<ext:PagingToolbar ID="pager" runat="server">
<Items>
<ext:ToolbarSeparator runat="server" />
<ext:ComboBox ID="cmbRecordPage"
runat="server"
Editable="false"
Width="175"
meta:resourcekey="cmbRecordPage">
<Listeners>
<Change Handler="onChangeRowPerPage(item, newValue)" />
</Listeners>
<Items>
<ext:ListItem Text="10" Value="10" />
<ext:ListItem Text="20" Value="20" />
<ext:ListItem Text="25" Value="25" />
<ext:ListItem Text="40" Value="40" />
<ext:ListItem Text="50" Value="50" />
<ext:ListItem Text="100" Value="100" />
</Items>
</ext:ComboBox>
<ext:ToolbarSeparator runat="server" />
<ext:ImageButton ID="cmdView"
runat="server"
ImageUrl="~/images/TS/Pos/17/002_1_VIEWER.png"
meta:resourcekey="cmdView">
<DirectEvents>
<Click OnEvent="OnViewerClick">
<ExtraParams>
<ext:Parameter Name="Record"
Value="getSysRecords(Ext.encode(#{gridRecord}.getRowsValu es({selectedOnly : true})))"
Mode="Raw" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:ImageButton>
<ext:ImageButton ID="cmdDownload"
runat="server"
ImageUrl="~/images/TS/Pos/17/015.png">
<DirectEvents>
<Click OnEvent="OnDownloadClick">
<ExtraParams>
<ext:Parameter Name="Record"
Value="getSysRecords(Ext.encode(#{gridRecord}.getRowsValu es({selectedOnly : true})))"
Mode="Raw" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:ImageButton>
<ext:ImageButton ID="cmdIndexes"
runat="server"
ImageUrl="~/images/TS/Pos/17/072.png">
<DirectEvents>
<Click OnEvent="OnIndexesClick" />
</DirectEvents>
</ext:ImageButton>
<ext:ImageButton ID="cmdCustomSort"
runat="server"
ImageUrl="~/images/TS/Pos/17/032d.png">
<DirectEvents>
<Click OnEvent="OnCustomSortClick" />
</DirectEvents>
</ext:ImageButton>
</Items>
</ext:PagingToolbar>
</TopBar>
<Listeners>
<AfterRender Handler="
this.down('headercontainer').on('headerclick', function (header, col, e, element) {
getViewBySerial(getSerial()).hide();
})" />
<ColumnShow Fn="saveHiddenColumns" />
<ColumnHide Fn="saveHiddenColumns" />
<SelectionChange Handler="onGridSelectionChanged(item, selected)" />
<SortChange Handler="onSortChange(item, column, direction)" />
</Listeners>
</ext:GridPanel>


and I reconfigure with this DirectMethod:



/// <summary>Esegue il bind di un recordset ad una griglia</summary>
/// <param name="serial">Seriale dell'archivio</param>
/// <param name="page">Numero dalla pagina da visualizzare</param>
[DirectMethod]
public void BindArchive(string serial, int page = 1)
{
GridPanel panel = X.GetCmp<GridPanel>("content_container_" + serial + "_gridRecord");
try
{
using (Fault.ActionThrow())
{
if (!serial.IsNullOrEmpty())
{
if (page <= 0)
page = 1;
m_archivio = new Archivio(Global.Current.Config, serial);
m_archivio.SourceRowsFrom = (page - 1) * RecordPerPage;
m_archivio.SourceRows = RecordPerPage;
m_archivio.SourceFilter = WhereCondition;

if ((KindCondition != SortKind.Indexes) && (!SortCondition.IsNullOrEmpty()))
m_archivio.SourceSort = SortCondition;

// Apro l'archivio
if (m_archivio.Open())
{
// Imposta lo store con il numero di record da visualizzare
m_store = gridRecord.GetStore();
m_store.PageSize = RecordPerPage;
// Imposta il numero di record totali
PageProxy p = m_store.Proxy.Primary as PageProxy;
if (p != null)
p.Total = m_archivio.GetSourceCount();
// Aggiorno la griglia
X.Js.Call("Ext.suspendLayouts");
panel.Reconfigure(_GetStore(), _GetColumns());
X.Js.Call("Ext.resumeLayouts", true);
}
}
}
}
catch (Exception ex)
{
Fault.Catch(ex);
}
}

/// <summary>Ritora un oggetto con le colonne da aggiungere alla griglia</summary>
/// <returns>Colonne lette dall'archivio</returns>
private IEnumerable<ColumnBase> _GetColumns()
{
List<ColumnBase> column = new List<ColumnBase>();
try
{
using (Fault.ActionThrow())
{
using (EDMConfigSettings settings = Global.Current.Config.Settings())
{
// Recupero le colonne da nascondere
List<string> cols = settings.Utente.Archivio(Serial).SysHidden.ToList( );
SiteHelper.RemoveEmptyString(ref cols);
column.Add(GetCheckBoxColumn());
// Creo una lista con tutte le colonne dell'archivio
foreach (DataColumn dc in m_archivio.Columns)
{
string name = dc.ColumnName;
ColumnBase c;
if (dc.DataType == typeof(DateTime))
{
c = new DateColumn
{
Format = (name == "SYS_CLOCK")
? "HH:mm"
: "dd/MM/yyyy"
};
}
else
{
c = new Column
{
Align = (dc.DataType.IsNumber())
? Alignment.Right
: Alignment.Left
};
}
c.Text = name;
c.DataIndex = name;
c.Flex = 1;
c.Width = 150;
c.MinWidth = 150;
c.Hidden = name.IsSysObjectName() && (cols.Count <= 0
? !m_colDisplayed.Contains(name)
: cols.Contains(name));
column.Add(c);
}
}
}
}
catch (Exception ex)
{
Fault.Catch(ex);
}
return column;
}

/// <summary>Imposta lo store da agganciare alla griglia</summary>
/// <returns>Store impostato</returns>
private AbstractStore _GetStore()
{
Store store_serial = new Store();
store_serial.ID = "store_" + Serial;
store_serial.PageSize = RecordPerPage;
if ((KindCondition == SortKind.Grid) && (!SortCondition.IsNullOrEmpty()))
{
string[] condition = SortCondition.Split(',');
for (int i = 0; i < condition.Length; i++)
{
string v = condition[i];
store_serial.Sorters.Add(new DataSorter
{
Property = v.Split(' ')[0].TrimBrace('[', ']'),
Direction = (v.Contains("ASC") || v.Split(' ').Length == 1)
? SortDirection.ASC
: SortDirection.DESC
});
}
}
try
{
using (Fault.ActionThrow())
{
if (m_archivio.IsOpen)
{
store_serial.Data = m_archivio.Table;
foreach (DataColumn dc in m_archivio.Columns)
{
SortTypeMethod sortType = SortTypeMethod.AsUCString;
if (dc.DataType.IsNumber())
sortType = SortTypeMethod.AsInt;
else if (dc.DataType == typeof(DateTime))
sortType = SortTypeMethod.AsDate;
store_serial.Fields.Add(new ModelField
{
SortType = sortType,
Name = dc.ColumnName,
Type = dc.DataType.MappingType()
});
}
}
}
}
catch (Exception ex)
{
Fault.Catch(ex);
}
return store_serial;
}


but in the chrome's console I view this error

Uncaught TypeError: Cannot read property 'isSynchronous' of null ext.axd?v=30649:40515
Ext.define.getStoreListeners ext.axd?v=30649:40515
Ext.define.bindStoreListeners ext.axd?v=30649:40250
Ext.define.bindStore ext.axd?v=30649:40225
Ext.define.bindStore ext.axd?v=30649:40496
Ext.define.setMaskBind ext.axd?v=30649:94710
Ext.define.onBindStore ext.axd?v=30649:94701
Ext.define.bindStore ext.axd?v=30649:40226
Ext.define.bindStore ext.axd?v=30649:94634
Ext.define.onBindStore ext.axd?v=30649:94703
Ext.define.bindStore ext.axd?v=30649:40226
Ext.define.bindStore ext.axd?v=30649:94634
Ext.define.bindStore ext.axd?v=30649:103726
Ext.define.reconfigure ext.axd?v=30649:103799
(anonymous function) VM15332:59
Ext.net.DirectEvent.Ext.data.Connection.executeScr iptDelay ext.axd?v=30649:1407
Ext.net.DirectEvent.Ext.data.Connection.executeScr ipt ext.axd?v=30649:1398
Ext.net.DirectEvent.Ext.data.Connection.requestSuc cessHandler ext.axd?v=30649:1335
Ext.apply.callback ext.axd?v=30649:7241
Ext.define.onComplete ext.axd?v=30649:32939
Ext.define.onStateChange ext.axd?v=30649:32898
(anonymous function)

I've understand that problem is PageProxy, but I do not understand how resolve it.
Can anyone help me?

multimediait
Apr 01, 2014, 1:17 PM
I've noted that issue occurs with version 2.5 and not with version 2.4

Daniil
Apr 01, 2014, 5:44 PM
Hi @multimediait,

Thank you for the report, but could you, please, provide us with a standalone runnable test case?

Please try AutoDestroy="false" for the Store.

multimediait
Apr 01, 2014, 6:22 PM
Thank you Daniil for reply, unfortunately,it's difficult make a test project, because there is many (business) projects linked, tomorrow I will try AutoDestroy="false".
If this flag is not working, there are others things that I check?

Daniil
Apr 02, 2014, 1:35 AM
I have no idea what else to try.

multimediait
Apr 02, 2014, 5:05 PM
unfortunately, AutoDestroy doesn't work, the only workaround found is back to version 2.4

Daniil
Apr 03, 2014, 2:44 AM
We would much appreciate if you can provide us with a full test case to reproduce.