file paths from sql to grid

Hello all,

I’m trying to load a link into grid for files which users will upload, they are in the format: …/…/uplaods/blah.pdf. How can I implement links without using XML? The only documentation I’ve found so far only talks of using XML:

Dummy link
    Real link^http://dhtmlx.com
    Real link^http://dhtmlx.com^_blank
    Real link^javascript:doSomething("param1","param2","param3")^_self

Also in another post I saw Olga said to use beforeRender…

Can someone please explain, in detail, what needs to be changed to have these links loaded into a cell?

Thanks in advance

What format of data do you have in your grid?
You can use the indicated format of a link in json or xml without any issues.
Just don’t forget to set the type of the column to “link” (dhtmlxgrid_excell_link.js is required).

JSON:

rows:[ { id:1001, data:[ "1000", "Blood and Smoke", "Stephen King^http://www.stephenking.com/the_author.html", "0", "1", "01/01/2000"] }, ...

XML:

<?xml version="1.0" encoding="UTF-8"?> <rows> <row id="1"> <cell>Blood and Smoke</cell> <cell>Stephen King^http://www.stephenking.com/the_author.html</cell> </row>

Hi Sematik,

Thanks for your reply.

All my data is loaded from the sql server. I have set the column type to link, dhtmlxgrid_excell_link.js is included. File paths are stored as “somename.pdf”. All links point to a file stored on my server. I haven’t hard pathed them because I haven’t purchased a domain yet.

I’ve never worked with JSON before, is there no way to do this from the connector? Or do i have to generate the XML file from the connector?

Below is a copy past of my code so you can have a look:

	<script src="../../dhtmlx/codebase/dhtmlx.js" type="text/javascript"></script>
    <!-- dhtmlx.css contains styles definitions for all included components -->
    <link rel="STYLESHEET" type="text/css" href="../../dhtmlx/codebase/dhtmlx.css">
    <script src="../../dhtmlx/codebase/connector/connector.js" type="text/javascript"></script>
    <script src="../../dhtmlx/codebase/ext/dhtmlxgrid_export.js" type="text/javascript"></script>
    <script src="../../dhtmlx/codebase/excells/dhtmlxgrid_excell_link.js" type="text/javascript"></script>
 	<script src="../../dhtmlx/codebase/dhtmlxgridcell.js" type="text/javascript"></script>
 
    <script type="text/javascript">
var layout,toolbar,custGrid;
dhtmlx.image_path = "../../dhtmlx/codebase/imgs/";
dhtmlxEvent(window,"load",function(){
    //layout
    layout = new dhtmlXLayoutObject("layout","1C");
    layout.cells("a").setText("Customer");
	layout.cells("a").setWidth(400);
	

toolbar = layout.attachToolbar();
toolbar.setIconsPath("../../icon/");
toolbar.loadXML("../../dhtmlx/codebase/xml/customer_files_master.xml");
		
custGrid = layout.cells("a").attachGrid();
    //contactGrid.setImagePath("./codebase/imgs/");
    //contactGrid.setSkin("dhx_skyblue");
custGrid.setHeader("File ID, Billing ID, Shipping ID, Company Name, File Name, File Type, File Description, file");
custGrid.attachHeader("#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter");
custGrid.setInitWidths("130,130,130,130,130,130,130,130");
custGrid.setColAlign("left,left,left,left,left,left,left,left");
custGrid.setColTypes("ro,ro,ro,ro,ro,ro,ro,link");
custGrid.setColSorting("str,str,str,str,str,str,str,str");
custGrid.enableSmartRendering(true);
custGrid.init();
custGrid.load("customer_files_master_connector.php");		

//toolbar
toolbar.addText("exportPDF", 1,'<a href="../../dhtmlx/codebase/grid-pdf-php/generate.php">Print to PDF</a>');
toolbar.addText("newCust", 2,'<a href="customer_files_add.php"><img src="../../icon/savesmall16.png" width="18" height="18"/></a>');
toolbar.attachEvent("onclick",function(id){
    if(id=="delCust"){
       var rowId = custGrid.getSelectedRowId();
       if(rowId!=null){
          var selectedIndex = custGrid.getRowIndex(rowId)
          custGrid.deleteRow(rowId);
          if(selectedIndex!=(custGrid.getRowsNum()-1)){
             custGrid.selectRow(selectedIndex+1,true);
          }
          else{
             custGrid.selectRow(selectedIndex-1,true)
          }
        }
    }
});

var dpg = new dataProcessor("customer_files_master_connector.php");
dpg.init(custGrid);

})
    </script>

Here you can find the list of format of data supported by the dhtmlxGrid:
docs.dhtmlx.com/doku.php?id=dhtm … ta_loading

Your connector should generate an xml.
Example here:
dhtmlx.com/docs/products/dht … d_dyn.html