cancel
Showing results for 
Search instead for 
Did you mean: 

How to search for only one property in Object Table offline in MDK

dwipal
Explorer
0 Kudos

I have enabled the search property to TRUE and as its behaviour, it is going to search for all the properties that are binded in the table. So how to make it work for only one property. 

View Entire Topic
Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos

You can write a rule for the Object Table Target Query Options to customize the search string to restrict the required search.

E.g., 

export default function SearchCustomer(context) {
let pageProxy = context.getPageProxy();
let search = context.searchString;
let qoB = context.dataQueryBuilder();
if(search && search != ''){
let productname = qoB.filterTerm(`substringof(tolower('${search}'),tolower(Name))`);
qoB.filter().or(fname);
return qoB;
}
}
 
In this case, search will look only for Name property. 
You can find more details on customizing query options using Data query builder here.
dwipal
Explorer
0 Kudos
Hello @Jitendra_Kansal, I am applying this rule in the QueryOptions but still it is not fetching the result properly. Is there anything i am missing out?
Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Kudos
@dwipal Could you share the rule and page schema to have a look what you tried?
dwipal
Explorer
0 Kudos

 

 

Hello @Jitendra_Kansal, Here i am shring page schema and rule which i have created.

{
	"Controls": [
		{
			"_Type": "Control.Type.SectionedTable",
			"_Name": "SectionedTable0",
			"Sections": [
				{
					"_Type": "Section.Type.ContactCell",
					"Target": {
						"Service": "/MDKApp/Services/sample.service",
						"EntitySet": "WSoldToSet",
						"QueryOptions": "/MDKApp/Rules/SearchCustomerListName.js"
					},
					"_Name": "SectionContactCell0",
					"Visible": true,
					"EmptySection": {
						"FooterVisible": false
					},
					"Separators": {
						"TopSectionSeparator": false,
						"BottomSectionSeparator": true,
						"HeaderSeparator": true,
						"FooterSeparator": true,
						"ControlSeparator": true
					},
					"ContactCell": {
						"Visible": true,
						"ContextMenu": {
							"PerformFirstActionWithFullSwipe": true
						},
						"DetailImage": "res://contact.png",
						"Headline": "{Name1}",
						"Subheadline": "{Btgew}",
						"Description": "{Anzpk}"
					},
					"DataPaging": {
						"ShowLoadingIndicator": false,
						"PageSize": 50
					},
					"Search": {
						"Enabled": true
					}
				}
			],
			"FilterFeedbackBar": {
				"ShowAllFilters": false,
				"_Type": "Control.Type.FilterFeedbackBar"
			}
		}
	],
	"_Type": "Page",
	"_Name": "Customer_List",
	"Caption": "Customer_List",
	"PrefersLargeCaption": true
}

Rule 

/**
 * Describe this function...
 * @param {IClientAPI} context
 */
export default function SearchCustomerListName(context) {

    let pageProxy = context.getPageProxy();
    console.log("pageProxy",pageProxy)
    let search = context.searchString;
    console.log("search",search)
    let qoB = context.dataQueryBuilder();
    console.log("qoB",qoB);
    if(search && search != ''){
        let productname = qoB.filterTerm(`substringof(tolower('${search}'),tolower(Name1))`);
        console.log("productname",productname);


        const test = qoB.filter().or(productname);
        console.log("test",test);

    }
    return qoB;
}