EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: dan on March 19, 2015, 01:30:38 AM



Title: jquery easyui datagrid row link help
Post by: dan on March 19, 2015, 01:30:38 AM
Hi, I'm trying to write a custom link on a datagrid. The user has the usual functions 'edit', 'add' & 'delete' but I'm also adding 'view'. All my code works apart from the view function but I cannot work out how to open the selected row in a custom url. What I want to achieve is the user selects a row and then clicks the view button which then transfers the id to the report url.

He's my code that works;-

    function editOrder(){
        var row = $('#dg').datagrid('getSelected');
        if (row){
            $('#dlg').dialog('open').dialog('setTitle','Edit Order');
            $('#fm').form('load',row);
            url = '/include/functions/edit/edit_order.php?id='+row.id;

and here is the code I've tried out but I cant get to work;-

    function viewOrder(){
        var row = $('#dg').datagrid('getSelected');
        if (row){

        $('#fm').form('load',row);
        url = '/include/functions/reports/purchase_order.php?id='+row.id;

Any help is appreciated


Title: Re: jquery easyui datagrid row link help
Post by: dan on March 25, 2015, 07:48:26 AM
Help anyone, please????  :'( :'(


Title: Re: jquery easyui datagrid row link help
Post by: stworthy on March 25, 2015, 08:19:28 AM
How do you define the 'view' link? Please describe your question in more detail.


Title: Re: jquery easyui datagrid row link help
Post by: dan on March 25, 2015, 08:51:12 AM
hi, sorry for the confusion.

I've added another button to the header similar to new/edit/delete but I cant establish the link. Basically the user selects a row (similar to edit) and clicks the view button. It then should transfer this ROW ID to an external page located at /include/functions/reports/purchase_order.php?id='ROW ID HERE; which then displays additional information from the database.

thanks


Title: Re: jquery easyui datagrid row link help
Post by: chrwei on March 26, 2015, 11:15:30 AM
I'm not sure I understand the difference between working and not working.  what's the value of url variable after?


Title: Re: jquery easyui datagrid row link help
Post by: dan on March 27, 2015, 12:45:33 AM
I'm not sure I understand the difference between working and not working.  what's the value of url variable after?

Hi Chrwei, the editOrder code is a working script. I've tried to modify this code in order to open the row ID in another URL. Essentially the jquery easyui datagrid displays minimal details and this url is like a report which will display more values from the database.

I appreciate your help.


Title: Re: jquery easyui datagrid row link help
Post by: chrwei on March 27, 2015, 06:01:00 AM
yes, but they looks the same, so you need to provide more details


Title: Re: jquery easyui datagrid row link help
Post by: dan on March 27, 2015, 09:14:07 AM
yes, but they looks the same, so you need to provide more details

Hi again, the second code doesnt work and is what I've tried to modify. When I use the form and click the view button it does nothing.

Below is the code I have started but it does not work correctly, I believe it is nearly there;-
function viewOrder(){
        var row = $('#dg').datagrid('getSelected');
        if (row){

        $('#fm').form('load',row);
        url = '/include/functions/reports/purchase_order.php?id='+row.id;


Title: Re: jquery easyui datagrid row link help
Post by: dan on April 01, 2015, 01:07:35 AM
I've managed to be able to load the 'ID' of the selected row using one of the tutorials, here is my code;-

      function viewOrder(){
         var row = $('#dg').datagrid('getSelected');
         if (row){
                alert('Item ID:'+row.id);
         }

I just cannot seem to be able to transfer this row 'ID' to my URL = /include/functions/reports/purchase_order.php?id=

Any ideas anyone???


Title: Re: jquery easyui datagrid row link help
Post by: dan on April 02, 2015, 01:00:24 AM
Hi all,

I've seen another post which states to use 'window.open' function but again this isn't working for me,  I have something slightly wrong with my code but cannot seem to locate the issue - any ideas people?

      function viewOrder(){
         var row = $('#dg').datagrid('getSelected');
         if (row){          
              window.open(http://WEBSITENAME/include/functions/reports/purchase_order.php?id=)+row.id;   
         }


Title: Re: jquery easyui datagrid row link help
Post by: dan on April 02, 2015, 01:36:49 AM
Solved!

for those who need to know it should be;-
url = "/include/functions/reports/purchase_order.php?id=" +row.id;
                window.open(url);