Skip to Content
author's profile photo Former Member
Former Member

how to use filters in sap.m.select?

Hello Team

I am new to UI5 , started developing a mobile App with two dropdown(sap.m.select) controls. The values are passed from sap to these fields.

from First drop down, selected value will be used to filter the second drop down . In the change event of the first dropdown i am able to get the selected value i need to know how do i filter the value based on the first drop down selected value. in JSON i have a key Parent which sets the link between the fields.

//var tfilter = new sap.ui.model.Filter("parent",sap.ui.model.FilterOperator.EQ,bKeySelected);

var tdropdown = new sap.m.Select("Category_test",{

items:{

path:"/categories",

template:new sap.ui.core.Item({

text: '{descr}',

key: '{cat}'

})

},

content:[

new sap.m.Label({text:"Department:"}) ,

/* oDropdownBox,*/

new sap.m.Select("Dept",{

items: {

path:"/departments",

template:new sap.ui.core.Item({

text: '{descr}',

key : '{dept}'

})

},

change:function(oControlEvent){

bSelected = oControlEvent.getParameter("selectedItem").getProperty("text");

bKeySelected = oControlEvent.getParameter("selectedItem").getKey();

//var Odata_Dept =

  1. tdropdown.setModel(categoryjson).addStyleClass('dep1Cls'),

alert(bSelected); alert(bKeySelected);

}

}).setModel(departmentJsonModel).addStyleClass('dep1Cls'),

new sap.m.Label({text:"Category:"}) ,

tdropdown,

{

"departments":[

{

"dept":"0021",

"descr":"21 LUMBER"

},

{

"dept":"0022",

"descr":"22 BUILDING MATERIALS"

},

{

"dept":"0059",

"descr":"59 BLINDS AND WALLPAPER"

}

],

"categories":[

{

"parent":"0021",

"cat":"0205",

"descr":"CONSTRUCTION MATERIALS"

},

{

"parent":"0021",

"cat":"0206",

"descr":"DECK & FENCE"

},

{

"parent":"0021",

"cat":"0207",

"descr":"EXTERIOR HOME"

},

{

"parent":"0021",

"cat":"0208",

"descr":"INTERIOR FINISHING"

},

{

"parent":"0021",

"cat":"0209",

"descr":"MISCELLANEOUS"

},

{

"parent":"0021",

"cat":"0210",

"descr":"OTHER-21"

},

{

"parent":"0022",

"cat":"0211",

"descr":"EXTERIOR PROJECTS"

},

{

"parent":"0022",

"cat":"0212",

"descr":"INTERIOR PROJECTS"

},

{

"parent":"0022",

"cat":"0213",

"descr":"LADDERS"

},

{

"parent":"0022",

"cat":"0214",

"descr":"MISCELLANEOUS"

},

{

"parent":"0022",

"cat":"0215",

"descr":"OTHER-22"

},

{

"parent":"0023",

"cat":"0216",

"descr":"CEILING TILE"

},

{

"parent":"0023",

"cat":"0217",

"descr":"HARD FLOORING"

},

{

"parent":"0023",

"cat":"0218",

"descr":"ORGANIZATION"

},

{

"parent":"0023",

"cat":"0219",

"descr":"OTHER-23"

},

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jan 02, 2014 at 08:01 PM

    change:function(oControlEvent){

    bSelected = oControlEvent.getParameter("selectedItem").getProperty("text");

    bKeySelected = oControlEvent.getParameter("selectedItem").getKey();

    //var Odata_Dept =

    var tfilter = new sap.ui.model.Filter("parent",sap.ui.model.FilterOperator.EQ,bKeySelected);

    /*var categoryBinding = tdropdown.getBinding("items");

    categoryBinding.filter=([tfilter]);*/

    tdropdown.bindAggregation("items",tfilter);

    //tdropdown.setModel(categoryjson).addStyleClass('dep1Cls'),

    alert(bSelected); alert(bKeySelected);

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.