dm-开发知识片段积累

1. Ext 滚动条事件:

  // 滚动条处在底端  --根据ID= history_panel 找到组件,设置滚动条所处位置
     Ext.getCmp("history_panel").body.scroll('b', 10000, {
            duration : 0.1
     });

 

  // 直接用panel组件,设置滚动条

  auditDemandInfo.body.scroll('b', 10000, {  // b-- bottom 底部  10000 是滚动多少像素,0.5 是滚动持续时间
              duration : 0.5
     });

  // 滚动条处在顶端

  auditDemandInfo.body.scroll('t', 10000, {   // t-- top 顶部  10000 是滚动多少像素,0.5 是滚动持续时间
                 duration : 0.5
      });

 

   知识点:

  ①FormPanel.el.getScroll();//得到滚动条对象

            ----//对象内容 {left:(scrollLeft),top:(scrollTop)}

            an object containing the scroll position in the format {left: (scrollLeft), top: (scrollTop)}

     ②FormPanel.el.isScrollable();//判断对象是否可以滚动

 

  ③scroll(方向,滚动多少,是否动画);

           scroll( String direction, Number distance, [Boolean/Object animate] ) : Boolean

      Scrolls this element the specified direction. Does bounds checking to make sure the scroll is within this element's scrollable range.

      Parameters:

          * direction : String 方向参数 l:左边滚动 ,r:右边滚动, t:上边滚动, b:下滚动
                 Possible values are: "l" (or "left"), "r" (or "right"), "t" (or "top", or "up"), "b" (or "bottom", or "down").
          * distance : Number
                    How far to scroll the element in pixels
          * animate : Boolean/Object
                  (optional) true for the default animation or a standard Element animation config object

     ④ scrollIntoView( [Mixed container], [Boolean hscroll] ) : Ext.Element

   ⑤ scrollTo(往哪滚动,滚动多少,动画否);
    scrollTo( String side, Number value, [Boolean/Object animate] ) : Element

    A.Scrolls this element the specified scroll point. It does NOT do bounds checking so if you scroll to a weird value it will try to do it.For

       auto bounds checking, use scroll().

 

    B. Parameters:

        * side : String
              Either "left" for scrollLeft values or "top" for scrollTop values.
        * value : Number
              The new scroll value
        * animate : Boolean/Object
              (optional) true for the default animation or a standard Element animation config object

    C. Returns:

        * Element
            this

 

 

2. JS

 -- 跳转至锚点     

  // 超链接标记 加上name值
  <a name="anchor"></a>


  // 在所要执行跳转到锚点的时候(或事件),改变location的hash值
  location.hash="anchor";

  -- 循环加载

  setTimeout(function() {
//                    if (!me._isRun) {          // 控制循环的变量
//                        return;
//                    }
                    me._fnLoadAppendMesgFunc(_demandId);
                    
                    setTimeout(arguments.callee, 1000);
                }, 1000);

3. Extjs 加载html片段,对按钮的位置进行控制。

  --由于Ext会优先使用其自己的样式,当加载html片段的时候,可能产生如下问题:

    1)如果html片段中的标记 --其样式表:css是采用外联的方式进行管理,那么可能会失效。

    2)可能导致html标记,不能继承父节点的样式

 

      如:html 片段:

  <div>

   <div style ="text-align:right;">

    <input type="button" class="button appendBtn-gblue"  onclick="_fnDemAppendMesgFunc();" value="追加信息"/>

   </div>

   <div class="appendMesgDivClass"  id="appendMesgDivId" style="font-size:25px;">

   </div>

  </div>

    由于其中button 引入了外部的一个css样式,虽然该button被div块包了起来,但实际并没有继承父节点div的样式,也就是该按钮靠右。

    最终的解决方案: 在html片段的button元素中,采用内联方式定义了一个属性 float: right 浮动靠右

          但是带来了另一个问题,其后的html元素内容会因此被该按钮给遮挡,最终在button后面的元素中对浮动进行清除,问题解决。

   

  <div>

   <div style ="text-align:right;">

     <input type="button" style ="float:right;" class="button appendBtn-gblue"  onclick="_fnDemAppendMesgFunc();" value="追加信息"/>

   </div>

   <div class="appendMesgDivClass"  id="appendMesgDivId" style="font-size:25px; clear: both;">

   </div>

  </div>

    

4.Eclipse 快捷键:

 

   ctrl + alt + h  -- 查看哪些地方调用了该方法

 ctrl +shift + g  -- 查看这个类被哪些调用

  

5. Ext 知识点碎片:

      ①// 隐藏域 xtype: hidden -----> hideLabel : true,    
                                                  hidden : true,

  ②// *号 : 在表单后面加上*号做为录入提示。
      A.{
            xtype : 'label',
            html : '<font color="red">*</font>&nbsp;'
         }

    

         B. fieldLabel:'<span class="red">*</span>文本输入 ',

   // 竖条 | 

     html : '<table width=100% border="0" cellspacing="0" cellpadding="0" height=100%>

          <tr>

            <td width="1" bgcolor="#F4F4F4">

            </td>

          </tr>

        </table>'

 

    ③ // tbar按钮居右  

    加入:{xtype : "tbfill"}   或者 ‘->',

         如:将showBtn展现在tbar的右侧:

        tbar:['-',backBtn,{xtype : "tbfill"},showBtn]  或者

        tbar:['-',backBtn,'->',showBtn]

              PS: 上面的'-' 出来的效果是分割线 |

      ④ // form表单:给fieldLabel 赋值----改变标签名 其中auditDesc是field的id:

      Ext.DomQuery.selectNode('label[for=auditDesc]').innerHTML = '请输入未通过的原因:'

     ⑤ // 表单-添加键盘监听事件
    {

         xtype: 'textfield',

         fieldLabel: 'Title',

         name: 'title',

         allowBlank: false,

         listeners: {

                  specialkey: function(f,e){

                           if (e.getKey() == e.ENTER) {

                                   movie_form.getForm().submit();

                           }

                  }

         }

    }

 

6. Oracle知识碎片: 

  oracle字段增删改
  ①.增加字段
  alter table table_name add newColumn varchar2(200)

  ②.删除字段
  ALTER TABLE table_name DROP COLUMN column_NAME

  ③.修改字段类型
     alter table test modify test1 varchar2(100);

  ④.修改字段名
     alter table test rename column test1 to test3;

  ⑤.添加主键:Alter table tabname add primary key(col)
    删除主键:Alter table tabname drop primary key(col)

  ⑥.创建索引:create [unique] index idxname on tabname(col….)
    删除索引:drop index idxname


        注:索引是不可更改的,想更改必须删除重新建。

  ⑦.创建视图:create view viewname as select statement
     删除视图:drop view viewname


  表操作记录eg:
    
  1.(审核历史表)

      //审核历史表 删除dev_task_id
      ALTER TABLE tbm_audit_h DROP COLUMN dev_task_id
    
      //审核历史表 增加rela_id
      ALTER TABLE tbm_audit_h add rela_id  NUMBER(20,0);
        
      //审核历史表 增加rela_type
      alter table tbm_audit_h add rela_type integer;  

  2.(审核表同上)

  3.(开发任务表)

  // 增加了开发任务名称字段
  alter table tbm_dev_task add dev_task_name VARCHAR2(250);

  4. (系统环节表)

  alter table tpm_system_tache add turn_state integer;

  5. (附件关联表)
        alter table tsm_attach_rela add tache_code VARCHAR(64);
        alter table tsm_attach_rela add rela_id NUMBER;
        alter table tsm_attach_rela add rela_type integer;

  

--创建表
--cteate table 表名(
         --字段名 数据类型 约束,
         --字段名 数据类型 约束
--)
Create table stu(
  Sid number(10),
  Sname varchar2(10)
) tablespace tt;
--以上 tablespace不是必须的。默认不写,则创建在登录的用户所在的表空间上
 select * from all_tables where owner='SCOTT'

--使用子查询创建表
create table myemp as select * from emp;                 创建一张与emp表 结构和数据完全相同的表
create table myemp as select * from emp where deptno=10;   创建一张只有部分结果的新表 
create table myemp as select * from emp where 1=2;              创建一张只有emp表的结构,但是不含任何结果的空表

 

--添加字段
--alter table 表名 add 新列字段名 数据类型;
Alter table stu add age number(3); 
                                                                                                                 
--修改字段
--alter table 表名 modify 字段名 新的数据类型
Alter table stu modify Sage number(10);
--alter table 表名 rename column 原来的名字 to 新的名字;
alter table stu rename column age to Sage;


--删除字段
--alter table 表名 drop column 列名
Alter table stu drop column Sage;

 

--清空表中数据 delete ,回滚
--清空表中数据
Truncate table student;  
--则表示所删除的数据不可恢复了.所以速度很快

--删除表
Drop table student;

--重命名表
Rename student to student1;

 

-- 插入数据
INSERT INTO person(pid,name) VALUES (11,'张三');
 
--PRIMARY KEY:主键约束
--不能重复,不能为空
--例如:身份证号不能为空。 
 
--UNIQUE:唯一约束,值不能重复(空值除外)
--人员中有电话号码,电话号码不能重复。 
 
--CHECK:条件约束,插入的数据必须满足某些条件
--人员有年龄,年龄的取值只能是0~150岁之间
DROP TABLE person ;
CREATE TABLE person
(
 pid  NUMBER PRIMARY KEY NOT  NULL,  
 name VARCHAR(30)  NOT NULL ,
 tel  VARCHAR(50)  NOT NULL UNIQUE ,
 age  NUMBER   CHECK(age BETWEEN 0 AND 150)
) ;


-- 插入数据
INSERT INTO person(pid,name,tel,age) VALUES (11,'张三','1234567',30);
-- 年龄的输入错误
INSERT INTO person(pid,name,tel,age) VALUES (12,'李四','2345678',-100);
 
--Foreign Key:外键 
                                                                                                                        
 
alter 命令为表添加约束
--、 为两个表添加主键:
--• person表 pid为主键:
   ALTER TABLE person ADD CONSTRAINT person_pid_pk PRIMARY KEY(pid) ;
--为person表中的 tel添加唯一约束:
  ALTER TABLE person ADD CONSTRAINT person_tel_uk UNIQUE(tel) ;
--为person表中的 age添加检查约束:
  ALTER TABLE person ADD CONSTRAINT person_age_ck CHECK(age BETWEEN 0 AND 150) ;
--为book表中的 pid添加与 person的主-外键约束,要求带级联删除
  ALTER  TABLE  book  ADD  CONSTRAINT  person_book_pid_fk  FOREIGN  KEY  (pid)
  REFERENCES person(pid) ON DELETE CASCADE ;
--删除约束:
 ALTER TABLE book DROP CONSTRAINT person_book_pid_fk ;
alter table student drop unique(tel);
--启用约束
ALTER TABLE book enable CONSTRAINT person_book_pid_fk ;
--禁用约束
ALTER TABLE book disable CONSTRAINT person_book_pid_fk ;

 

--视图:是一个封装了各种复杂查询的语句,就称为视图。
--CREATE VIEW  视图名字(字段) AS  子查询
create view empv_all as select * from scott.emp;

 

--创建序列
Create sequence myseq
Start with 1  
Increment by 1  
Order
cache 20 --设置是否在内存里缓冲
Nocycle;
--NextVal,CurrVal
Select myseq.nextval from dual;
Select myseq.currval from dual;
--(必须先有 nextval,才能有currval)

                                                                                                                      
--查询完之后就已经自增 1了

create table t1 (

       id int
      
)
select * from t1;
Insert into t1 values(myseq.nextval)  --这时候已经是2了
 
--Cycle,Cache
--而用了 nocycle,就可以确保当该序列用于多张表的时候,ID 是唯一的
 
--用 cycle时,用法如下:
create sequence myseq2 start with 1 increment by 1 cycle maxvalue 3
nocache ;

Select myseq2.nextval from dual;
Select myseq2.currval from dual;
--这样到3之后,要会重新从1开始  
--如果指定CACHE值,ORACLE就可以预先在内存里面放置一些sequence,这样存取的快些。cache里
--面的取完后,oracle自动再取一组到cache。 使用cache或许会跳号, 比如数据库突然不正常down掉
--(shutdown abort),cache中的sequence就会丢失. 所以可以在create sequence的时候用nocache防止
--这种情况
 
--不能改变当前值,但是可以改变增量
Alter sequence myseq increment by 3;


--同义词
--在任何一个用户下,都可以直接访问 dual,而不需要加上前缀的用户名如:scott.emp
Select * from dual;
 
--为什么?因为同义词的存在  
--Dual其实是sys用户下的一张表
select table_name from user_tables where lower(table_name) = 'dual';  
--作用:
--很方便的操作不同用户下的对象
--能使两个应用程序使用不同的名字指向同一张表
--使用不同的用户指向同一张表的。

Create synonym dept for soctt.dept;--(这样创建的同义词是私有的,只有创建者才能用)
Drop synonym dept;
Create public synonym dept for soctt.dept;--(这样创建的同义词才是公有的)
Drop public synonym dept;

 

--建立索引
create index emp_ix on emp(ename);

 

// 时间特别注意: 如--

// 更新字段值 (日期)
update tbm_audit  set ask_time = TO_DATE('2014/5/11 5:44:13','yyyy-mm-dd hh24:mi:ss'); 

 

   

 

  

posted @ 2014-04-25 13:08  吐故纳新  Views(171)  Comments(0)    收藏  举报