﻿// JScript 文件
// JScript 文件

//demoLayout
var NewsCompanyDataSet;
var NewsIndustryDataSet;

var NewsCompanyGridView;
var NewsIndustryGridView;

Ext.onReady(function (){    
	var layoutCompany = new Ext.BorderLayout('FirstPageCompanyNews',{
			        center: {
			            autoScroll: true
			        }
			    });	
   var layoutIndustry = new Ext.BorderLayout('FirstPageIndustryNews',{
			        center: {
			            autoScroll: true
			        }
			    });		
       
	    if(!NewsCompanyDataSet){
	        NewsCompanyGridView();
	    }
	    if(!NewsIndustryDataSet){
	        NewsIndustryGridView();
	    }
   
});

function NewsCompanyGridView(){
   
    NewsCompanyDataSet = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({url:GlobarInterfacePagingUrl}),
        reader: new Ext.data.XmlReader({
              record: 'WWW_NEWS',
              id: 'NEWSID',
              totalRecords: 'results'
              }, [ 
                  'NEWSID','NEWSTYPEID','NEWSSTYLE','NEWSTITLE','NEWSAUTHOR','NEWSFROM','NEWSIMAGEIS','FBSJ','VISITCOUNT'
               ])
    });
   
    var cm = new Ext.grid.ColumnModel([
   //   {header: "NEWSID", width: 80, dataIndex: 'NEWSID'},
  //    {header: "新闻类型", width: 80, dataIndex: 'NEWSTYPEID'},
   //   {header: "NEWSSTYLE", width: 80, dataIndex: 'NEWSSTYLE'},
      {header: "", width: 310, dataIndex: 'NEWSTITLE'},
    //  {header: "NEWSCONTEXT", width: 80, dataIndex: 'NEWSCONTEXT'},
    //  {header: "作者", width: 80, dataIndex: 'NEWSAUTHOR'},
   //   {header: "NEWSFROM", width: 80, dataIndex: 'NEWSFROM'},
   //   {header: "NEWSIMAGEIS", width: 80, dataIndex: 'NEWSIMAGEIS'},
      {header: "", width: 80, dataIndex: 'FBSJ'}
   //   {header: "VISITCOUNT", width: 80, dataIndex: 'VISITCOUNT'}
  ]);
  cm.defaultSortable = true;
  var mySelectionModel = new Ext.grid.RowSelectionModel();
  NewsCompanyGridView = new Ext.grid.EditorGrid('FirstPageCompanyNews', {
      ds: NewsCompanyDataSet,
      cm: cm,
      selModel: mySelectionModel,
    //  autoSizeColumns: true,
      monitorWindowResize: false,      
      trackMouseOver: true
   });
   var columnModel = NewsCompanyGridView.getColumnModel();
  
   NewsCompanyGridView.render();
 
  NewsCompanyGridView.on('rowclick',DetailsWWW_NEWS);
  function DetailsWWW_NEWS(btn, pressed){
      var row = NewsCompanyGridView.getSelectionModel();      
      window.open(GlobalRootUrl+'News/NewsPage.aspx?newsId='+row.getSelected().get('NEWSID'));
  }
  
  var param = 'DataGridNewsFirstPage';
  var paramXml ="";//getPackXML(getxml(user));
  NewsCompanyDataSet.load({params:{start:0, limit:4,param:param,paramXml:paramXml}});
    
}

function NewsIndustryGridView(){
   
    NewsIndustryDataSet = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({url:GlobarInterfacePagingUrl}),
        reader: new Ext.data.XmlReader({
              record: 'WWW_NEWS',
              id: '',
              totalRecords: 'results'
              }, [ 
                  'NEWSID','NEWSTYPEID','NEWSSTYLE','NEWSTITLE','NEWSAUTHOR','NEWSFROM','NEWSIMAGEIS','FBSJ','VISITCOUNT'
               ])
    });
   
    var cm = new Ext.grid.ColumnModel([
   //   {header: "NEWSID", width: 80, dataIndex: 'NEWSID'},
  //    {header: "新闻类型", width: 80, dataIndex: 'NEWSTYPEID'},
   //   {header: "NEWSSTYLE", width: 80, dataIndex: 'NEWSSTYLE'},
      {header: "", width: 310, dataIndex: 'NEWSTITLE'},
    //  {header: "NEWSCONTEXT", width: 80, dataIndex: 'NEWSCONTEXT'},
    //  {header: "作者", width: 80, dataIndex: 'NEWSAUTHOR'},
   //   {header: "NEWSFROM", width: 80, dataIndex: 'NEWSFROM'},
   //   {header: "NEWSIMAGEIS", width: 80, dataIndex: 'NEWSIMAGEIS'},
      {header: "", width: 80, dataIndex: 'FBSJ'}
   //   {header: "VISITCOUNT", width: 80, dataIndex: 'VISITCOUNT'}
  ]);
  cm.defaultSortable = true;
  var mySelectionModel = new Ext.grid.RowSelectionModel();
  NewsIndustryGridView = new Ext.grid.EditorGrid('FirstPageIndustryNews', {
      ds: NewsIndustryDataSet,
      cm: cm,
      selModel: mySelectionModel,
    //  autoSizeColumns: true,
      monitorWindowResize: false,
      trackMouseOver: true
   });
  
   NewsIndustryGridView.render();
 
 
  NewsIndustryGridView.on('rowclick',DetailsWWW_NEWS);
  function DetailsWWW_NEWS(btn, pressed){
      var row = NewsIndustryGridView.getSelectionModel();      
      window.open(GlobalRootUrl+'News/NewsPage.aspx?newsId='+row.getSelected().get('NEWSID'));
  }
  
  var param = 'DataGridNewsIndustryFirstPage';
  var paramXml ="";//getPackXML(getxml(user));
  NewsIndustryDataSet.load({params:{start:0, limit:4,param:param,paramXml:paramXml}});
    
}