How can I use "Multi Filter Select" by literal javascript

How can I use "Multi Filter Select" by literal javascript

GuilhermeOliveiraSGuilhermeOliveiraS Posts: 2Questions: 1Answers: 0

I've been using the dataTable by a literal field in asp.net, but if I try to use the Multi Filter Select as an initialization parameter, nothing happens.

Follows the code:

StringBuilder str = new StringBuilder();

str.Append(@"

var dataSet = ["); for (int i = 0; i < countRows; i++) { str.Append(@[""); //fill row for (int j = 0; j < countColumn; j++) { data = dt.Rows[i][j].ToString(); str.Append(data); str.Append(@""","""); } //complete the row str.Append(@"""],"); } str.Append(@]; $(document).ready(function() { $('#example').DataTable({ // I can't use the parameter of Multi Filter Select here "scrollY"": 200, ""scrollX"": true, ""scrollCollapse"": true, ""paging"": false, data: dataSet, columns: [ "); //fill column name for (int i = 0; i < countColumn; i++) { columnName= dt.Columns[i].ColumnName.ToString(); str.Append(@{ title: ""); str.Append(columnName); str.Append(@""" },"); } str.Append(@] }); }); ); str.Append("

");

            //literal field
            lt.Text = str.ToString();

Thanks in advance.

Answers

  • GuilhermeOliveiraSGuilhermeOliveiraS Posts: 2Questions: 1Answers: 0

    ```StringBuilder str = new StringBuilder();

    str.Append(@"<script type='text/javascript'> var dataSet = [");

               ``` for (int i = 0; i < countRows; i++)
                {
                    str.Append(@"[""");```
    
    
                    ```//fill rows
                    for (int j = 0; j < countColumn; j++)
                    {
                        data= dt.Rows[i][j].ToString();
                        str.Append(data);
                        str.Append(@""",""");
                    }```
    
    
                    str.Append(@"""],");
                }```
    
    
          ```      str.Append(@"];```
    

    $(document).ready(function() { $('#example').DataTable({

           ``` ""scrollY"": 200,
            ""scrollX"": true,
            ""scrollCollapse"": true,
            ""paging"": false,
            data: dataSet,
            columns: [  ");```
    
               ``` //captura nome das colunas
                for (int i = 0; i < countColumn; i++)
                {
                    columnName= dt.Columns[i].ColumnName.ToString();
    
                    str.Append(@"{ title: """);
                    str.Append(columnName);
                    str.Append(@""" },");
                }
    
                str.Append(@"]
        });
            }); ");```
    
    
                ```str.Append("</script>");
                lt.Text = str.ToString();```
    
This discussion has been closed.