queryView

returns inner element/elements of a widget that correspond(s) to the defined parameters

object|array queryView(object|function|string config, [string mode] );
configobject|function|stringan object with search parameters, a function with the search logic or a string with the view type
modestringoptional, the mode of search: "all","parent","self", see details
object|arraya view object or an array of view objects in the "all" mode

Example

// searches for an element with the specified properties
var element = $$("layout").queryView({ width: 100, height: 200 });
 
// searches for a certain view in the widget
var button = $$("layout").queryView({ view:"button" });
 
// or a shorter way with the string parameter
var button = $$("layout").queryView("button");
 
// searches for all entities of the specified view
var buttons = $$("layout").queryView({ view:"button" }, "all");
var buttons = $$("layout").queryView("button", "all");
 
// searches for all button elements and disables them
var btns = $$("layout").queryView({ view:"button" },"all").map(view => view.disable()); 
 
// searches for all elements the width of which is more than 100px
var elements = $$("layout").queryView(function(view){
    return view.config.width > 100;
});

Related samples

Details

The possible modes of search are:

  • "all" - to return all corresponding elements
  • "parent" - changes the search direction, the parent element with the specified parameters is searched for
  • "self" - besides inner elements of the widget the method will return the widget itself, if it corresponds to the search parameters
Back to top
Join Our Forum
We've retired comments here. Visit our forum for faster technical support, connect with other developers, and share your feedback there.