retrieve value from a slick grid table

549 views Asked by At

This is how my slick grid table looks like. and the rows are added on the function. How can I write a function in js to get the slick-cell l0 r0 value from each class. so I want to get temp,temp2, sss and test33 values

I am new to this slick grid thing so any help will be really appreciated.

  <div class="grid-canvas" style="height: 206px; width: 390px;">
    <div class="ui-widget-content slick-row even" style="top:0px">
        <div class="slick-cell l0 r0">temp</div>
        <div class="slick-cell l1 r1">test group</div>
        <div class="slick-cell l2 r2 edit-column"></div>
        <div class="slick-cell l3 r3 delete-column"></div>
    </div>
    <div class="ui-widget-content slick-row odd" style="top:25px">
        <div class="slick-cell l0 r0">temp2</div>
        <div class="slick-cell l1 r1">test g 2 </div>
        <div class="slick-cell l2 r2 edit-column"></div>
        <div class="slick-cell l3 r3 delete-column"></div>
    </div>  
    <div class="ui-widget-content slick-row even" style="top:100px">
        <div class="slick-cell l0 r0">sss</div>
        <div class="slick-cell l1 r1">sss</div>
        <div class="slick-cell l2 r2 edit-column"></div>
        <div class="slick-cell l3 r3 delete-column"></div>
    </div>

    <div class="ui-widget-content slick-row odd" style="top:125px">
        <div class="slick-cell l0 r0">test33</div>
        <div class="slick-cell l1 r1">test33</div>
        <div class="slick-cell l2 r2 edit-column"></div>
        <div class="slick-cell l3 r3 delete-column"></div>
    </div>
</div>
2

There are 2 answers

2
Fábio Duque Silva On

I have never used slickgrid, and I don't know if you have any built-in function that helps you, but if you can use plain-old jQuery, you can try it like this:

var output = $(".slick-row").find(".l0.r0").map(function () {
  return $(this).text();
}).get();

console.log(output);

// Output will be
// Array[4]
//   0: "temp"
//   1: "temp2"
//   2: "sss"
//   3: "test33"

Check this jsFiddle and open the console to see the result:

https://jsfiddle.net/fabio_silva/5n3s6hra/

0
Saransh Kataria On

you want the first column in every row. Why not use slickgrid's inbuilt functions rather than jquery?