Question

I'm working on a project with ext.net which has a paginator inside the toolbar of an HtmlEditor

Markup is:

<ext:Hidden ID='HF_type' runat="server"/>
    <ext:HtmlEditor ID="HtmlEditor1" runat="server" Height="800" Width="1050"
        EnableAlignments="false"
        EnableColors="false"
        EnableFont="false"
        EnableFontSize="true"
        EnableLinks="false"
        EnableLists="false"
        EnableSourceEdit="false"
        Maximizable="false"
    >
        <Listeners>
            <Initialize Handler="ButtonInit(#{HtmlEditor1})" />
            <Render     Handler="ButtonRender(#{HtmlEditor1})" />

        </Listeners>
    </ext:HtmlEditor>

Toolbar render function:

function ButtonRender(he){
he.getToolbar().add([{xtype:'tbseparator'}]);

he.getToolbar().addButton([{
    id:'previousBtn',
    iconCls:'arrow-left',
    handler: function(){previousPageClick();},
    scope: this,
    tooltip: 'Pagina precedente',
    overflowText: 'Pagina precedente'
}]);

he.getToolbar().addField( [{
   id:'pageCounter',
    xtype : 'tbtext',
    text : '1 di 3',
    width: '40'
}]);

he.getToolbar().addButton([{
    id:'nextBtn',
    iconCls:'arrow-right',
    handler: function(){nextPageClick();},
    scope: this,
    tooltip: 'Pagina successiva',
    overflowText: 'Pagina successiva'
}]);

he.getToolbar().add([{xtype:'tbseparator'}]);

he.getToolbar().addButton([{
    iconCls:'icon-printer-color',
    handler: function(){pdfClick();},
    scope: this,
    tooltip: 'Stampa',
    overflowText: 'Stampa'
}]);

Everything is working fine: Buttons are added, page changes work etc. The only problem that i have is that in the "pageCounter" textfield of the toolbar the text is "1 di 3" but it could also be "1 di 2". How can i change this value depending on certain conditions?

To explain better: I need that on page load the textfield appears with different number depending on number of pages.

Was it helpful?

Solution

Lol. Apparently posting a question in stackoverflow brings good luck. Figured it out. I added 2 hiddenfields which contain current and total number of pages and that i fill on page load. With this code i change it on load:

Ext.onReady(function() {
var theCounter = #{HtmlEditor1}.getToolbar().get("pageCounter");
theCounter.setText(HF_currentPage.value + ' di ' + HF_totalPages.value);
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top