How to place two SlickGrid grids on one page?

How to place two SlickGrid grids on one page? Just having one slickgrid (jquery control) requires a lot of specific commands and using an unnamed function (it seems). So what if I want two controls or more on one page?

There is something about declaring a jquery function:

$ (function () {

what prevents it from working. This is not really a feature declaration. Thus, there cannot be $ (function2 () {for the second grid.

Just duplicating the contents of the second grid in the sample code, I get somethnig, which is efficient. Do you see where I am wrong?

enter code here 

Well, that didn't work. I will need an ftp code and place a link to it on the website.

+4
source share
2 answers

I'm not quite sure if I understand your problem. You can create as many Slick.Grid instances as you wish:

 var grid1 = new Slick.Grid("#firstGrid", someData, someColumns, someOptions); var grid2 = new Slick.Grid("#secondGrid", otherData, otherColumns, otherOptions); 
+1
source

I agree with idbehold's answer. You can create and display several slickgrids on one page.

eg. Your .js file should resemble

 var grid1; var data1=[]; var columns1=[ //relevant code ]; var grid2; var data2=[]; var columns2=[ //relevant code ]; var options={ //relevant code }; //You can also create separate options for each grid, //but take care to include those as arguments when //initializing the grid. $ function() { // relevant code grid1 = new Slick.Grid("#myGrid1", data1, columns1, options); //or options1 grid2 = new Slick.Grid("#myGrid2", data2, columns2, options); //or options2 // more code } 

Note. Please ensure that all brackets are properly closed. Above is just to show what your code should look like. I tried to use such code successfully.

0
source

Source: https://habr.com/ru/post/1494791/


All Articles