0 0

WCF得不到Extjs传来的参数。5

用wcf+extsj做树形结构,但是wcf得不到extjs传来的id值。
xtype : 'treepanel',
											// useArrows : true,
											autoScroll : true,
											id:'treeLoader',
											animate : true,
											enableDD : true,
											height : 710,
											enableDrag : true,
											 containerScroll : true,
											 checkModel:'cascade ',
											 loader : new Ext.tree.TreeLoader({	
										        listeners :{										            
										            'beforeload':function(treeLoader,node )
										            {										                
										                alert(node.attributes.id);										                
										                [color=red]this.baseParams.id=node.attributes.id;//这里id传值到wcf,但是wcf得不到。不过我alert可以得到id,或者用下面的方法也可以。[/color]
										                
//										                treeLoader.baseParams={
//						                                                    id :node.id
//						     
						                                                     //method : 'loadTree'
//					                                                           };
										            }
										        },
										         dataUrl:'../Common/PageGridService.svc/loadTree'
										        
											 }),
											root : new Ext.tree.AsyncTreeNode({
														text : 'OA前臺系統管理',
														draggable : false,
														id :'0'
														//children : j
													})

wcf代码如下。
[WebInvoke(Method = "*", RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json,
        UriTemplate = "loadTree?id={id}")]//不知道是不是申明有错误。
      public string loadTree(string id)
        {
           
            NavigateDataContext ctx = new NavigateDataContext();
            var res = from n in ctx.Navigate
                     where n.parentid == id//这里的id为null,
                     select n;
            string json="[{";
            foreach(var s in res)
            {
               json=json+ "id:"+s.id+",text:"+s.title;
               if (s.leaf == 1)
               {
                   json = json + ",leaf:" + "true";
               }
               else
               {
                   json = json + ",leaf:" + "false";
               };
            }
            json = json + "}]";
             return json ;
        } 请帮忙指点一下。多谢。
2008年12月05日 12:27
目前还没有答案

相关推荐

Global site tag (gtag.js) - Google Analytics