cancel
Showing results for 
Search instead for 
Did you mean: 

Form binding with oData based on input values

0 Kudos

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

Qualiture
Active Contributor
0 Kudos

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'

0 Kudos

Hi Robin,

Thanks for ur reply

i have tried with following,

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


still its not working.


the actual value i mentioned above is working fine in table ,bindaggregation method.

but the same is not working in form binding.


anyother helpful ideas pls?

Qualiture
Active Contributor
0 Kudos

I'm not really sure, but I think the ODataModel only supports inline $expand and $select, not $filter

So I think you should get the binding from the model first, then create the filter, and then add it to the binding:

var oBinding = oModel.bindList("/creditDataSet");

var oFilter1 = new sap.ui.model.Filter("Creditcontrolarea", sap.ui.model.FilterOperator.Equals, input1); 

var oFilter2 = new sap.ui.model.Filter("Customer", sap.ui.model.FilterOperator.Equals, input2); 

oBinding.filter([oFilter1, oFilter2]);

santhu_gowdaz
Active Contributor
0 Kudos

try,

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

0 Kudos

Hi Robin,

I changed my code as yours, still its not working.

0 Kudos

Hi santhosh,

Thanks for your reply.

i tried with the same, still not getting binding output.

Anyother  relative examples.

and  this is service

is there any problem in service.

Former Member
0 Kudos

Hello Chandran,

I am also trying same scenario and also I am not able to do it. Can you please share the details if you are able to do it.

Thanks,

Pad


0 Kudos

Hi Gurung,
    
     I solved this issue by mapping Get_Entity in Service implementation. The problem is with service implementaion.

Former Member
0 Kudos

Hello Chandran,

In my case I am not able to bind the odata data into simple form can you please help me. or please share the sample code how to achieve this.

Senario : Read Odata with 2 filter parameter. Bind the data to the simple form. not to able to bind with XML view.

Thanks,

Pad

0 Kudos

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