Skip to Content

Form binding with oData based on input values

Hi everyone ,

In sap.m , XML view i need to display a form , in which the field values should change dynamically,

in accordance with my input and button press.

my UI looks like the below

this is my "controller.js"  code:

-----------------------------------------------------

press: function() {

input1=this.getView().byId("inp1").getValue();

input2=this.getView().byId("inp2").getValue();


var path= "/creditData1Set?$filter=Creditcontrolarea'+' '+'eq'+' '+"'"+input1+"'"+' '+'and'+'   '+'Customer'+''+'eq'+' '+"'"+input2+"'" " ;

var frm = this.getView().byId("form_id");

frm.bindElement(path);

}

-----------------------------------------------------

but its not working

is this right way to bind oData to a Form.

pls suggest if having any idea on this.

thanks,

Chandran.

screenshot.png (8.2 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jul 28, 2015 at 12:47 PM

    I see a lot of funky '+' operators and rogue single/double quotes in your string object, that doesn't seem right. You may want to debug the actual value of your variable 'path'

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Gurung,

      //    --------------------------   view.xml  -----------------------------------

      <f:SimpleForm     id="simpleform"

                              minWidth="1024"

                              maxContainerCols="2"

                              layout="ResponsiveGridLayout"

                                labelSpanL="4"

                              labelSpanM="4"

                              labelSpanS="4"

                              emptySpanL="1"

                              emptySpanM="1"

                              emptySpanS="1"

                              columnsL="2"

                              columnsM="2"

                              columnsS="1">

                                           

                      <f:content>

                          <core:Title text="{Title}" />

                          <Label text="First Name" />         <Text  text="{Firstname}"/>

                          <Label text="Last Name" />         <Text  text="{Lastname}"/>

                          <Label text="City" />                <Text  text="{City}" />

                         

      </f:content>

      </f:SimpleForm>

      // ---------------------------------- controller.js ---------------------

      // get input1 and input2 values

      var simple_frm  = this.getView().byId("simpleform")

      simple_frm.bindElement('/fm_credit1Set(IM_parametr1='+"'"+input1+"'"+',IM_parametr2='+"'"+input2+"'"+')');

      make sure that you have implemented 'Get_Entity (READ)' operation in your oData service.

      Regards ,

      Chandran