/** * Expand tree through provided path * * @param array path from highest node to the last * @return Riesenia\Utility\Kendo\Tree */ public function expand($path = []) { $this->widget->setDataBound(Kendo::js('function (e) { var expand = $("#' . $this->_id . '").data("expand"); // initial if (typeof expand === "undefined") { expand = ' . json_encode($path) . '; } if (expand.length) { var id = expand.shift(); // select if last node or expand this node var node = this.findByUid(this.dataSource.get(id).uid); if (!expand.length) { this.select(node); } else { this.expand(node); } $("#' . $this->_id . '").data("expand", expand); } }')); return $this; }
/** * Return JavaScript * * @return string */ public function script() { $rangeCode = ''; // range from if ($this->_rangeFrom) { $rangeCode = '$("#' . $this->_rangeFrom . '").data("' . $this->widget->name() . '").max(this.value() ? this.value() : this.max());'; } // range from if ($this->_rangeTo) { $rangeCode = '$("#' . $this->_rangeTo . '").data("' . $this->widget->name() . '").min(this.value() ? this.value() : this.min());'; } $this->widget->setChange(Kendo::js('function(e) { // date for hidden field var value = this.value(); $("#' . $this->_id . '-hidden").val(value ? kendo.date.addDays(value, value.getTimezoneOffset() / -1440).toISOString().substring(' . $this->_substringStart . ', ' . $this->_substringEnd . ').replace("T", " ") : ""); ' . $rangeCode . ' }')); $script = $this->widget->__toString(); $script .= 'setTimeout(function() { if ($("#' . $this->_id . '").length) { $("#' . $this->_id . '").data("' . $this->widget->name() . '").trigger("change"); } }, 1);'; return $script; }
/** * Set template providing only id * * @param string template id * @return Riesenia\Utility\Kendo\ListView */ public function setTemplateById($id) { $this->widget->setTemplate(Kendo::js('kendo.template($("#' . $id . '").html())')); return $this; }