0

How to use converter on data of listcell(MVC)

asked 2017-12-29 13:27:07 +0800

ansarism gravatar image ansarism
1

Hi,

I was using MVVM pattern and used @converter on data which worked seamlessly.

Due to version change, MVVM pattern cause some exception So we decided to work with MVC.

How to apply converter on data. Please help me write the appropriate code. where I go wrong in the following code. Watch out the first listcell tag of Listbox

<window id="win" apply="com.saidigital.qspj.backoffice.gui.controller.InvoiceSequenceController"
        validationMessages="@id('vmsgs')" onOpen="@globalCommand('loadPage')">

    <toolbar>
        <toolbarbutton id="addGuiSequenceButton" sclass="z-toolbarbutton"  label="${c:l('gui_sequence_toolbar_add_button')}" onClick="@command('guiCreateModel')" width="140px"/>
        <toolbarbutton id="closeGuiSequenceButton" sclass="z-toolbarbutton" disabled="${not win$composer.enableCloseGuiSequenceButton}" label="${c:l('gui_sequence_toolbar_close_button')}" onClick="@command('closeGUISequence')" width="100px"/>
        <toolbarbutton id="openGuiSequenceButton" sclass="z-toolbarbutton" disabled="${not win$composer.enableOpenGuiSequenceButton}" label="${c:l('gui_sequence_toolbar_open_button')}" onClick="@command('openGUISequence')" width="100px"/>
        <toolbarbutton id="stopGuiSequenceButton" sclass="z-toolbarbutton" disabled="${not win$composer.enableStopGuiSequenceButton}" label="${c:l('gui_sequence_toolbar_stop_button')}" onClick="@command('stopGUISequence')" width="100px"/>
        <toolbarbutton id="activeGuiSequenceButton" sclass="z-toolbarbutton" disabled="${not win$composer.enableActiveGuiSequenceButton}" label="${c:l('gui_sequence_toolbar_active_button')}" onClick="@command('activeGUISequence')" width="100px"/>
    </toolbar>

    <listbox id="guiSequenceListTable"
        model="${win$composer.guiSequenceModelList}" selectedItems="@{win$composer.selectedGUISequenceSet}" checkmark="true"
            multiple="true" mold="paging" pageSize="10" emptyMessage="GUI sequence numbers are not available.">
        <listhead>
            <listheader width="32px" />
            <listheader label="${c:l('gui_sequence_add_year')}" sortAscending="${cStartDateAsc}" sortDescending="${cStartDateDsc}"/>
            <listheader label="${c:l('gui_sequence_add_month')}" sortAscending="${cEndDateAsc}" sortDescending="${cEndDateDsc}" />
            <listheader label="${c:l('gui_sequence_prefix')}" sortAscending="${cPrefixAsc}" sortDescending="${cPrefixDsc}" />
            <listheader label="${c:l('gui_sequence_seq_no')}" />
            <listheader label="${c:l('gui_sequence_number_from')}" />
            <listheader label="${c:l('gui_sequence_number_to')}" />
            <listheader label="${c:l('gui_sequence_next_number')}" />
            <listheader label="${c:l('gui_sequence_remaining_numbers')}" />
            <listheader label="${c:l('gui_sequence_status')}" sortAscending="${cStatusAsc}" sortDescending="${cStatusDsc}" />
            <listheader label="${c:l('gui_sequence_close_status')}" sortAscending="${cCloseStatusAsc}" sortDescending="${cCloseStatusDsc}" />
        </listhead>
        <template name="model">
            <listitem>
                <listcell />
                <listcell label="${each.startDate} @converter(${win$composer.yearConverter})" />
                <listcell label="${each.endDate}" />
                <listcell label="${each.guiPrefix}" />
                <listcell label="${each.sequenceNumber}" />
                <listcell label="${each.numberFrom}" />
                <listcell label="${each.numberTo}" />
                <listcell label="${each.nextNumber}" />
                <listcell label="${each.remainingNumbers}" />
                <listcell label="${each.guiStatus ne null and each.guiStatus eq 'S' ? c:l('gui_sequence_status_STOP') : c:l('gui_sequence_status_ACTIVE')}" />
                <listcell label="${each.guiCloseStatus ne null and each.guiCloseStatus eq 'Y' ? c:l('gui_sequence_close_status_CLOSED') : c:l('gui_sequence_close_status_ACTIVE')}" />
            </listitem>
        </template>
    </listbox>
</window>
delete flag offensive retag edit

Comments

Lol, still MVVM if i look at your code.

chillworld ( 2017-12-31 14:11:44 +0800 )edit

can you give me sample code using converter using MVC Pattern?

ansarism ( 2018-01-02 12:28:45 +0800 )edit

I don't think you understand the consequences of that. @command, @global-command will not work anymore. Beside => the@{} is wrong MVVM usage, please use @bind for it with the selectedItem. If your problem comes from the @{}, change to `@init, @load, @save or @bind and your problems are solved

chillworld ( 2018-01-02 12:42:25 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-12-31 14:12:31 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

Just use @init in the line you want to use these converter

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2017-12-29 13:27:07 +0800

Seen: 5 times

Last updated: Dec 29 '17

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More