Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - [email protected]

Pages: [1]
1

How do I reference the cells in the grid, so I can loop through and write the changes back to the database?
Preferably only the changed rows.

2
That example doesn't work either.  Is it because I'm using the FREE version?

This is the code I cut and assembled from the example you provided, and it doesn't download either.


<!DOCTYPE HTML>
<html>
<head>

<!--jQuery dependencies-->
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/themes/base/jquery-ui.css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>   
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
<!--PQ Grid files-->
    <link rel="stylesheet" href="pqgrid.min.css" />
    <script src="pqgrid.min.js"></script>
<!--PQ Grid Office theme-->
    <link rel="stylesheet" href="themes/office/pqgrid.css" />


<script>
    $(function () {
        var data = [
            {rank:1, company:'Exxon Mobil',revenues: '339,938.0',profits: '36,130.0'},
            {rank:2, company:'Wal-Mart Stores',revenues: '315,654.0', profits:'11,231.0'},
          {rank:3, company:'Royal Dutch Shell', revenues:'306,731.0', profits:'25,311.0'},
          {rank:4, company:'BP', revenues:'267,600.0',profits: '22,341.0'},
          {rank:5, company: 'General Motors',revenues: '192,604.0', profits:'-10,567.0'},
          {rank:6, company: 'Chevron', revenues:'189,481.0', profits:'14,099.0'},
          {rank:7, company: 'DaimlerChrysler',revenues: '186,106.3',profits: '3,536.3'},
          {rank:8, company: 'Toyota Motor', revenues:'185,805.0',profits: '12,119.6'},
          {rank:9, company: 'Ford Motor', revenues:'177,210.0',profits: '2,024.0'},
          {rank:10, company: 'ConocoPhillips', revenues:'166,683.0', profits:'13,529.0'},
          {rank:11, company: 'General Electric',revenues: '157,153.0', profits:'16,353.0'},
          {rank:12, company: 'Total', revenues:'152,360.7', profits:'15,250.0'},
          {rank:13, company: 'ING Group', revenues:'138,235.3', profits:'8,958.9'},
          {rank:14, company: 'Citigroup', revenues:'131,045.0', profits:'24,589.0'},
          {rank:15, company: 'AXA', revenues:'129,839.2', profits:'5,186.5'},
          {rank:16, company: 'Allianz',revenues: '121,406.0', profits:'5,442.4'},
          {rank:17, company: 'Volkswagen', revenues:'118,376.6',profits: '1,391.7'},
          {rank:18, company: 'Fortis', revenues:'112,351.4', profits:'4,896.3'},
          {rank:19, company: 'Credit Agricole', revenues:'110,764.6', profits:'7,434.3'},
          {rank:20, company: 'American Intl. Group', revenues:'108,905.0',profits: '10,477.0'}
      ];

        var obj = {
            showTitle: false,
            height: 'flex',
            scrollModel: { autoFit: true },
            pageModel:{type:'local'},
            toolbar: {
                cls: 'pq-toolbar-export',
                items: [{
                        type: 'button',
                        label: "Export to CSV",
                        icon: 'ui-icon-document',
                        listeners: [{
                            "click": function (evt) {
                                $("#grid_export").pqGrid("exportCsv", { url: "/pro/demos/excel" });
                            }
                        }]
                }]
            }                       
        };
        obj.colModel = [       
            { title: "Rank", width: 100, dataType: "integer",dataIndx:"rank"},
            { title: "Company", width: 200, dataType: "string", dataIndx:"company"},
            { title: "Revenues ($ millions)", width: 150, dataType: "float", align: "right", dataIndx:"revenues" },
            { title: "Profits ($ millions)", width: 150, dataType: "float", align: "right", dataIndx: "profits" }
        ];
        obj.dataModel = {
            data: data,
            location: "local",
            sorting: "local",                                 
            sortIndx: "profits",
            sortDir: "down"           
        };
        var $grid = $("#grid_export").pqGrid(obj);
    });
</script>
</head>
<body>

    <div id="grid_export" style="margin: auto;">
    </div>


</body>
</html>



3

Hi,

I'm new to Param Query and it looks great!  I've successfully populated the grid from one of my database tables, but I can't figure out 2 things:

1) How to write data back to the table once its updated.
2) How to export to CSV. (I'm trying this as a starting point, but the button doesn't do anything, even though I've followed the examples.)

My program is listed below.

Any help is greatly appreciated.

Regards,
Paul




<!DOCTYPE HTML>
<html>
<head>
<!--jQuery dependencies-->
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/themes/base/jquery-ui.css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>   
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
<!--PQ Grid files-->
    <link rel="stylesheet" href="pqgrid.min.css" />
    <script src="pqgrid.min.js"></script>
<!--PQ Grid Office theme-->
    <link rel="stylesheet" href="themes/office/pqgrid.css" />

<script>
    <%
    myDSN   = "PROVIDER=SQLOLEDB;DATA SOURCE=" & Session("SystemServer") & ";INITIAL CATALOG=" & Session("SystemDatabaseName") & ";UID=" & Session("SystemUserName") & ";PWD=" & Session("SystemPassWord") & ""
    mySQL   = "select * from mine where active = 'Y' order by minename"
    set rs1 = server.createobject("adodb.recordset")
    rs1.open mySQL,myDSN
    myCount = 1
    myArray = "["
    Do While Not rs1.EOF
       myRowData = "['" & rs1.fields(0) & "', '" & rs1.fields(2) & "', '" & rs1.fields(13) & "', '" & rs1.fields(29)  & "', '" & rs1.fields(4) & "']"
       myArray = myArray & myRowData
       myCount = myCount + 1
       rs1.MoveNext
       if Not rs1.EOF then
          myArray = myArray & ","
       end if
    Loop
    myArray = myArray & "]"
    %>


    $(function () {

        var data = <%=myArray%>;

        obj.colModel = [
        { title: "Mine ID",    width: 25,  dataType: "string", align: "left" },
        { title: "Mine Name",  width: 150, dataType: "string", align: "left" },
        { title: "Classic ID", width: 100, dataType: "float",  align: "left"},
        { title: "Lat/Long",   width: 100, dataType: "string", align: "left"},
        { title: "Active",     width: 10,  dataType: "string", align: "center" }
        ];

        obj.dataModel = { data: data };
        $("#grid_array").pqGrid(obj);
        });

        var obj = {
            width: 1000,
            height: 500,
            title: "Timesheet Users Table",
            numberCell:{resizable:true, title: "#"},
            showTitle: true,
            height: 'flex',
            scrollModel: { autoFit: true },
            pageModel: { type: 'local' },
            toolbar: {
                cls: 'pq-toolbar-export',
                items: [{
                    type: 'button',
                    label: "Export to CSV",
                    icon: 'ui-icon-document',
                    listener: function () {
                        //debugger;
                        var zip = $("#zip_file").prop("checked");
                        this.exportCsv({
                            url: "/bin",
                            render: true,
                            zip: zip,
                            filename: 'my-file'
                        });
                    }
                },
                {
                    type: 'checkbox',
                    style: 'margin-right:10px;',
                    attr: 'id="zip_file"',
                    label: 'Zip the file'
                }]
            }
        };

</script>   
</head>

<body>
    <h1>Pauls Grid Example (https://paramquery.com/)</h1>
    <div id="grid_array" style="margin:0px;"></div>
</body>
</html>

4
I'm generating an array variable in the same format as the provided example, and for some reason the grid populates with only 1 character per column.

But if I copy/paste the variable contents into the code, it works.

So I don't understand why data2 works and data1 doesn't.

See variables data1 and data2 below in the code.

-------------------------------


<!DOCTYPE html>
<html>
<head>
<!--jQuery dependencies-->
   <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css" />
   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
   <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>

<!--PQ Grid files-->
    <link rel="stylesheet" href="pqgrid.min.css" />
    <link rel="stylesheet" href="pqgrid.ui.min.css" />
    <!--office theme-->
    <link rel='stylesheet' href='themes/office/pqgrid.css' />

    <script src="pqgrid.min.js"></script>
    <!--for localization and intellisense -->
    <script src="localize/pq-localize-en.js"></script>

<!--jqueryui touch punch for touch devices-->
    <script src="touch-punch/touch-punch.min.js"></script>

<!--jsZip for zip and xlsx import/export-->
    <script src="jsZip-2.5.0/jszip.min.js"></script>

<style>
    *{
        font-size:12px;
        font-family: Arial;
    }
</style>


<%
Session("SystemServer")         = "zzz"
Session("SystemDatabaseName")   = "zzz"
Session("SystemUserName")       = "zzz"
Session("SystemPassWord")       = "zzz"

myDSN   = "PROVIDER=SQLOLEDB;DATA SOURCE=" & Session("SystemServer") & ";INITIAL CATALOG=" & Session("SystemDatabaseName") & ";UID=" & Session("SystemUserName") & ";PWD=" & Session("SystemPassWord") & ""
mySQL   = "Select top 5 * from Mine order by MineID"
set rs1 = server.createobject("adodb.recordset")
rs1.open mySQL,myDSN

myArray = ""
Do While Not rs1.EOF
   myRowData = "[" & rs1.fields(0) & ", '" & rs1.fields(2) & "', 100.00, 200.00]"
   myArray = myArray & myRowData
   rs1.MoveNext
   if rs1.EOF then
      myArray = myArray & "<br>"
      exit do
   else
      myArray = myArray & ",<br>"
   end if
Loop
'response.write myArray
'response.end
%>

<script>

    $(function () {


   var data1 = [ "<%=myArray%>" ];

   var data2 =
   [
   [1, 'Argo', 100.00, 200.00],
   [2, 'Belleisle', 100.00, 200.00],
   [3, 'Cave Rocks', 100.00, 200.00],
   [4, 'Cosmo Howley', 100.00, 200.00],
   [5, 'Brocks Creek', 100.00, 200.00]
   ];

        var obj = {
            numberCell:{resizable:true,title:"#",width:30,minWidth:30},
            editor: {type: 'textbox'},
            title: "Pauls Data Grid",
            resizable:true,
            scrollModel:{autoFit:true, theme:true}
        };

        obj.colModel = [
            { title: "Record", width: 100, dataType: "integer" },
            { title: "Mine Name", width: 200, dataType: "string" },
            { title: "Number 1", width: 150, dataType: "string", format: '$#,###.00'},
            { title: "Number 2", width: 150, dataType: "string", format: '$#,###.00'},
            { title: "Number 3", width: 150, dataType: "float", format: '$#,###.00'},
            { title: "Number 4", width: 150, dataType: "float", format: '$#,###.00'},
            { title: "Number 5", width: 150, dataType: "float", format: '$#,###.00'},
            { title: "Number 6", width: 150, dataType: "float", format: '$#,###.00'},
            { title: "Number 7", width: 150, dataType: "float", format: '$#,###.00'},
        ];

        obj.dataModel = { data: data2 };
        $("#grid_array").pqGrid(obj);
    });


</script>
</head>
<body>
<div id="grid_array" style="margin:100px;"></div>

<%response.write myArray%>

</body>
</html>

5
Hi,
Still cant get it to work.  I'm not familiar with JSON and don't understand how it retrieves a result set from my database.  I setup another .asp file that simply retrieves a result set in the formatted array structure, and plugged that in to the JSON example, but it didnt render anything.  I'm stuck!
Regards,
Paul


6
Hi and thanks for your response.  I've downloaded the free version to test with.
I'll have a look at the demos your provided.
Thanks,
Paul


7
Hi,
I'm trialing the free version of Param Grid because it looks great!  I am attempting to populate it using an SQL query to my database.  I have structured the results from the query like the default example in the provided array.htm, but when I render the grid I only get 1 character per column, even though the variable I store the array in is identical to the default array in the array.htm example.  Any clues that could help me?
Thanks,
Paul

THIS IS THE DEFAULT ARRAY THATS PROVIDED (THE ONE I CREATED I AT THE END) ...
        var data = [
            [1, 'Exxon Mobil', 339938.0, 36130.0],
            [2, 'Wal-Mart Stores', 315654.0, 11231.0],
            [3, 'Royal Dutch Shell', 306731.0, 25311.0],
            [4, 'BP', 267600.0, 22341.0],
            [5, 'General Motors', 192604.0, -10567.0],
            [6, 'Chevron', 189481.0, 14099.0],
            [7, 'DaimlerChrysler', 186106.3, 3536.3],
            [8, 'Toyota Motor', 185805.0, 12119.6],
            [9, 'Ford Motor', 177210.0, 2024.0],
            [10, 'ConocoPhillips', 166683.0, 13529.0],
            [11, 'General Electric', 157153.0, 16353.0],
            [12, 'Total', 152360.7, 15250.0],
            [13, 'ING Group', 138235.3, 8958.9],
            [14, 'Citigroup', 131045.0, 24589.0],
            [15, 'AXA', 129839.2, 5186.5],
            [16, 'Allianz', 121406.0, 5442.4],
            [17, 'Volkswagen', 118376.6, 1391.7],
            [18, 'Fortis', 112351.4, 4896.3],
            [19, 'Crédit Agricole', 110764.6, 7434.3],
            [20, 'American Intl. Group', 108905.0, 10477.0]
        ];

MINE LOOKS LIKE THIS ...
[1, 'Argo', 100.00, 200.00],
[2, 'Belleisle', 100.00, 200.00],
[3, 'Cave Rocks', 100.00, 200.00],
[4, 'Cosmo Howley', 100.00, 200.00],
[5, 'Brocks Creek', 100.00, 200.00]


AND I INJECT THIS VARIABLE VALUE INTO THE PARAM QUERY JAVASCRIPT LIKE THIS ...
var data = [ "<%=myArray%>" ]


THIS IS THE FULL SOURCE CODE OF MY EXAMPLE ...

<!DOCTYPE html>
<html>
<head>
<!--jQuery dependencies-->
   <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css" />
   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
   <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>

<!--PQ Grid files-->
    <link rel="stylesheet" href="pqgrid.min.css" />
    <link rel="stylesheet" href="pqgrid.ui.min.css" />
    <!--office theme-->
    <link rel='stylesheet' href='themes/office/pqgrid.css' />

    <script src="pqgrid.min.js"></script>
    <!--for localization and intellisense -->
    <script src="localize/pq-localize-en.js"></script>

<!--jqueryui touch punch for touch devices-->
    <script src="touch-punch/touch-punch.min.js"></script>

<!--jsZip for zip and xlsx import/export-->
    <script src="jsZip-2.5.0/jszip.min.js"></script>

<style>
    *{
        font-size:12px;
        font-family: Arial;
    }
</style>


<%
Session("SystemServer")         = "XXXXXXXXX"
Session("SystemDatabaseName")   = "XXXXXXXXX"
Session("SystemUserName")       = "XXXXXXXXX"
Session("SystemPassWord")       = "XXXXXXXXX"

myDSN   = "PROVIDER=SQLOLEDB;DATA SOURCE=" & Session("SystemServer") & ";INITIAL CATALOG=" & Session("SystemDatabaseName") & ";UID=" & Session("SystemUserName") & ";PWD=" & Session("SystemPassWord") & ""
mySQL   = "Select top 5 * from Mine order by MineID"
set rs1 = server.createobject("adodb.recordset")
rs1.open mySQL,myDSN

myArray = ""
Do While Not rs1.EOF
   myRowData = "[" & rs1.fields(0) & ", '" & rs1.fields(2) & "', 100.00, 200.00]"
   myArray = myArray & myRowData
   rs1.MoveNext
   if rs1.EOF then
      myArray = myArray & "<br>"
      exit do
   else
      myArray = myArray & ",<br>"
   end if
Loop
'response.write myArray
'response.end
%>

<script>

    $(function () {


var data = [ "<%=myArray%>" ]


        var obj = {
            numberCell:{resizable:true,title:"#",width:30,minWidth:30},
            editor: {type: 'textbox'},
            title: "Pauls Data Grid",
            resizable:true,
            scrollModel:{autoFit:true, theme:true}
        };

        obj.colModel = [
            { title: "Record", width: 100, dataType: "integer" },
            { title: "Mine Name", width: 200, dataType: "string" },
            { title: "Number 1", width: 150, dataType: "string", format: '$#,###.00'},
            { title: "Number 2", width: 150, dataType: "string", format: '$#,###.00'},
            { title: "Number 2", width: 150, dataType: "float", format: '$#,###.00'},
            { title: "Number 2", width: 150, dataType: "float", format: '$#,###.00'},
            { title: "Number 2", width: 150, dataType: "float", format: '$#,###.00'},
            { title: "Number 2", width: 150, dataType: "float", format: '$#,###.00'},
            { title: "Number 2", width: 150, dataType: "float", format: '$#,###.00'},
            { title: "Number 2", width: 150, dataType: "float", format: '$#,###.00'},
            { title: "Number 2", width: 150, dataType: "float", format: '$#,###.00'}
        ];

        obj.dataModel = { data: data };
        $("#grid_array").pqGrid(obj);
    });

</script>
</head>
<body>
<div id="grid_array" style="margin:100px;"></div>



<%response.write myArray%>

</body>
</html>











Pages: [1]