I was trying to implement jsGrid in Polymer but was stuck where it required to get the target grid DOM element to the jsGrid()
function. Being unable to produce an equivalent to $("#jsGrid")
in Polymer.
I have already imported all the required source files in the polymer component file itself using the import
command.
// Render function
render(){
return html`
${jsGrid_css}
${jsGrid_theme_css}
<h2>Hello ${this.name}!</h2>
<div id="jsGrid"></div>
`;
}
// Render grid method
renderGrid(){
const gridEle = document.getElementById("jsGrid")
const gridNode = this.shadowRoot.querySelector("#jsGrid");
console.log($("#jsGrid"))
//--> output to this shows no element
$("#jsGrid").jsGrid({
width: "100%",
height: "400px",
inserting: true,
editing: true,
sorting: true,
paging: true,
data:this.clients,
fields: [
{ name: "Name", type: "text", width: 150, validate: "required" },
{ name: "Age", type: "number", width: 50 },
{ name: "Address", type: "text", width: 200 },
{ name: "Country", type: "select", items: this.countries, valueField: "Id", textField: "Name" },
{ type: "control" }
]
});
}
The grid is not being rendered on the html page when i am using $("#jsGrid")
. This could be due to the fact that jsGrid()
method is unable to get the DOM element with required properties when i replace $("#jsGrid")
with this.shadowRoot.querySelector("#jsGrid")
or with document.getElementById("jsGrid")
Thanks in advance!