[CLOSED] getting data from DisplayField in FormPanel

  1. #1

    [CLOSED] getting data from DisplayField in FormPanel

    Hi,

    I have a Formpanel containing DisplayFields. Data are initially loaded through a JsonPProxy and adjusted while using the webapplication.

    In the back I want to use the content of the DisplayFields. Unfortunately the values that are retreived are the initial Text, which I set on "0".
    When I use a TextField than the loaded content is passed as a value.

    Any idea why TextField.Text returns the latest data and DisplayField not? And is there a way to get the data directly from de DisplayField?


    <ext:FormPanel
        ID="FormPanelCntAllocation"
        runat="server"
        AutoDataBind="true">
        <Items>
            <ext:TextField ID="txtBruto" runat="server" Text="0"  DataIndex="bruto"></ext:TextField>
            <ext:DisplayField ID="dfBruto"  runat="server" Text="0" FieldLabel="Bruto:" DataIndex="bruto" >
            </ext:DisplayField>
        </Items>
    </ext:FormPanel>
    And in C#:
    int iBrutoFromDF = Convert.ToInt32(dfBruto.Text); // result: 0 conform Text="0"
    int iBrutoFromTF = Convert.ToInt32(txtBruto.Text); // result: 8560 conform data
    Hans Wapenaar
    Last edited by fabricio.murta; Jan 07, 2022 at 5:31 PM.
  2. #2
    Hello @HansWapenaar!

    Display Field is... well, not really a field despite its name. It acts more like a label, as such, it does not have an actual form field to submit when submission happens. Thus its value doesn't get known by direct methods and events when you make a server side call.

    In order to reliably access its current value from code behind, you'd need to pass it to the code behind as an ExtraParameter to the direct method or event.

    If you want the value to be changed dynamically it may be you want a text field either disabled="true" or readonly="true'.

    Another alternative is sync a ext:Hidden; this way you can map virtually any component into a form field -- as long as you keep their content in sync.

    - Example using the ext:Hidden component: GridPanel > Miscellaneous > Export_Data_PostBack

    - Example applying Data Binding (start from here, but look up its neighboring examples in Examples Explorer): Form > Miscellaneous > Data_Binding

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3

    getting data from FormPanel through hidden field

    Hi Fabricio,

    In my example I added a <ext:TextField> to the FormPanel. When relating the to the same DataIndex as the <ext:DisplayField> and setting Hidden=true I could get access to the new content of the data. I keep using the DisplayField for layout reasons. So without the box from a TextField.

    You suggested the <ext:Hidden> object. That seem to work even better: when adding a DataIndex to <ext:Hidden> the webapplication keeps the data in sync and the contents is accessible in the code behind.

    Thanks for your suggestions,

    Hans Wapenaar
  4. #4
    Hello again, Hans Wapenaar!

    Glad it helped, thanks for the feedback!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. How to format date in DisplayField in formpanel
    By xxjt123xx in forum 2.x Help
    Replies: 1
    Last Post: Jul 22, 2013, 8:53 PM
  2. [CLOSED] How to load FormPanel data using DirectMethods
    By jchau in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 18, 2012, 10:53 AM
  3. How to Submit FormPanel Data
    By abhijit in forum 1.x Help
    Replies: 3
    Last Post: Feb 24, 2012, 7:18 AM
  4. Replies: 12
    Last Post: Feb 20, 2012, 1:58 PM
  5. FormPanel that moves the load data
    By threewonders in forum 1.x Help
    Replies: 0
    Last Post: Feb 25, 2011, 8:48 AM

Posting Permissions