EasyUI Forum
September 14, 2025, 04:44:52 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Treegrid for asp.net and web method  (Read 16905 times)
ottoman-koc
Newbie
*
Posts: 2


View Profile
« on: October 03, 2012, 12:16:03 AM »

Hi everyone.
I'm tying to implement easyui treegrid into my asp.net application. I get the main nodes shown in grid. but the child nodes are not shown.

this is the javascript code;

Code:
$('#tt').treegrid({
        loader: function(param, success, error) {
            getServerData(param, success, error);
        },
        idField: 'InSysProjectTask',
        treeField: 'StTitle',
        frozenColumns: [[
           
       { field: 'StTitle', title: 'StTitle', width: 200,
           formatter: function(value) {
               return '<span style="color:red">' + value + '</span>';
           }
       }
]],
               columns: [[   { title: 'InSysProjectTask', field: 'InSysProjectTask', hidden: true},
       { field: 'InMainSysProjectTask', title: 'InMainSysProjectTask', hidden:true },
       { title: 'StDetail', field: 'StDetail', width: 40,
           formatter: function(value) {
           return '<img src="/images/comment.png" title="' + value + '"/>';
           }  },
       { title: 'StFullName', field: 'StFullName', width: 80  },
       { title: 'InIsMilestone', field: 'InIsMilestone', width: 80  },
       { title: 'InStatus', field: 'InStatus', width: 80  },
       { title: 'DtDueDate', field: 'DtDueDate', width: 80 },
       { title: 'DtEndDate', field: 'DtEndDate', width: 80 },
       { title: 'DtStartDate', field: 'DtStartDate', width: 80 },
       { title: 'InEstimatedWork', field: 'InEstimatedWork', width: 80  }
    ]]
    });

    function getServerData(param, success, error) {
        main_id = param.id;
        if (main_id == undefined)
            main_id = '94';
        jQuery.ajax({
            type: "POST",
            url: '/WebForm1.aspx/treeTest',
            data: JSON.stringify({ mainId: main_id }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(data) {
                var oColumns = { rows: jQuery.parseJSON(data.d) };
                success(oColumns);
            },
            error: function(jqXHR, textStatus, errorThrown) {
                alert(errorThrown);
            }
        });
    }

and below the web service
Code:
[System.Web.Services.WebMethod]
        public static string treeTest(string mainId)
        {
            string cn = SqlConnectionHelper.ConnectionString;
            string sqlStr = "SELECT tl.InSysProjectTask, tl.InMainSysProjectTask, tl.StTitle, " +
        " isNull(tl.StDetail, '') StDetail, convert(varchar, tl.DtDueDate, 104) DtDueDate, u.StFullName, InIsMilestone " +
        " ,InStatus, convert(varchar, DtEndDate, 104) DtEndDate, convert(varchar, DtStartDate, 104) DtStartDate, InEstimatedWork, " +
        "CASE WHEN (SELECT count(tsp.InSysProjectTask) FROM TbSysProjectTask tsp WHERE tsp.InMainSysProjectTask = tl.InSysProjectTask)>0 THEN 'closed' ELSE 'open' END AS [state]" +
        " FROM TbSysProjectTask tl " +
        " Left join TbUsers u on u.InUserId = tl.InResponsibleId " +
        " WHERE tl.InSysTicketProjectId=" + "13" + " AND tl.InSubProjectId=" + "94" + " AND tl.InMainSysProjectTask = " + mainId;

            DataSet ds = SqlHelper.ExecuteDataset(cn, CommandType.Text, sqlStr);
            return GetJson(ds.Tables[0]);
        }

this is what i got;




and this is when i try to get child nodes;



any help?
« Last Edit: October 03, 2012, 12:18:54 AM by ottoman-koc » Logged
ottoman-koc
Newbie
*
Posts: 2


View Profile
« Reply #1 on: October 03, 2012, 03:57:16 AM »

ok guys. i've just found solution to my own question  Smiley

i have changed the javascript getServerData function like this;

Code:
    function getServerData(param, success, error) {
        main_id = param.id;
        isRoot = false;
        if (main_id == undefined) {
            isRoot = true;
            main_id = '94';
        }
        jQuery.ajax({
            type: "POST",
            url: '/WebForm1.aspx/treeTest',
            data: JSON.stringify({ mainId: main_id }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(data) {
            var oColumns = new Array();
            if (isRoot)
                oColumns = { rows: jQuery.parseJSON(data.d) };
                 else
                     oColumns = jQuery.parseJSON(data.d);
                success(oColumns);
            },
            error: function(jqXHR, textStatus, errorThrown) {
                alert(errorThrown);
            }
        });
    }


and it's done! Smiley
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!