F

Namespace

F

Description:
  • F命名空间

Classes

Accordion
AccordionPane
Base
Button
ButtonGroup
Calendar
CheckBox
CheckBoxList
Component
Container
DataList
DatePicker
DropDownBox
DropDownList
Field
FileUpload
Form
Grid
GridColumn
GroupPanel
Hidden
HtmlEditor
Label
Menu
MenuCheckBox
MenuItem
MenuItemBase
MenuSeparator
MessageBox
NumberBox
PagingToolbar
Panel
PanelBase
RadioButton
RadioButtonList
Tab
TabStrip
TextArea
TextBox
TimePicker
Tool
Toolbar
ToolbarFill
ToolbarItemBase
ToolbarSeparator
ToolbarText
Tree
TriggerBox
ViewPort
Window

Members

(static) KEY

Description:
  • 键盘按键代码

键盘按键代码

Methods

(static) addCSS(id, content, isCSSFile)

Description:
  • 向页面添加CSS内容或者引用CSS文件

Parameters:
Name Type Description
id string

键(防止重复添加相同的内容)

content string

CSS内容或者CSS文件网址

isCSSFile boolean

是否CSS文件

(static) addCommas(string) → {string}

Description:
  • 添加千分位分隔符

Parameters:
Name Type Description
string string

数字

Returns:

包含千分位分隔符的字符串

Type
string

(static) addDotSeparator(string, dotSeparator, commaSeparator) → {string}

Description:
  • 添加小数分隔符

Parameters:
Name Type Description
string string

数字

dotSeparator string

小数分隔符

commaSeparator string

千分位分隔符(如果为undefined,则不添加千分位分隔符)

Returns:

包含小数分隔符的字符串

Type
string

(static) addJS(id, content, isJSFile)

Description:
  • 向页面添加JS内容或者引用JS文件

Parameters:
Name Type Description
id string

键(防止重复添加相同的内容)

content string

JS内容或者JS文件网址

isJSFile boolean

是否JS文件

(static) addMainTab(tabstripInstance, options, activedopt, moveToEndopt)

Description:
  • 添加选项卡

Parameters:
Name Type Attributes Default Description
tabstripInstance F.TabStrip

选项卡面板实例

options Object

选项卡参数

Properties
Name Type Default Description
id string ''

选项卡标识符

iframeUrl string ''

选项卡中内联框架的地址(默认启用iframe)

title string ''

选项卡标题

icon string ''

选项卡标题图标

iconFont string ''

选项卡标题图标字体

refreshWhenExist string ''

如果选项卡已经存在,是否刷新其中的内联框架

actived boolean <optional>
true

是否激活选项卡(默认为true)

moveToEnd boolean <optional>
false

将选项卡移到尾部(如果选项卡已存在,则不改变位置,默认值:false)

(static) addMainTabByHref(tabstripInstance, treeInstance, href, activedopt, moveToEndopt)

Description:
  • 添加选项卡(在树中查找拥有href的树节点)

Parameters:
Name Type Attributes Default Description
tabstripInstance F.TabStrip

选项卡面板实例

treeInstance F.Tree

树控件实例

href string

树节点的超链接网址

actived boolean <optional>
true

是否激活选项卡(默认为true)

moveToEnd boolean <optional>
false

将选项卡移到尾部(如果选项卡已存在,则不改变位置,默认值:false)

(static) alert(options)

Description:
  • 弹出提示对话框

Parameters:
Name Type Description
options Object

初始参数

Properties
Name Type Default Description
target string '_self'

显示对话框的目标位置(可选项为:_self, _parent, _top)

message string ''

消息正文

title string ''

标题文本(留空则使用默认标题)

messageIcon string 'information'

消息图标(可选项为:information, warning, question, error, success)

closable boolean true

是否可关闭

ok function

点击确认按钮时执行的回调函数

(static) beforeAjaxError(callback)

Description:
  • 注册AJAX回发失败回调函数(返回false则不执行默认的错误处理)

Example

自定义错误提示框

F.beforeAjaxError(function (data) {
	F.alert('服务器返回错误!');
	return false;
});
Parameters:
Name Type Description
callback function

AJAX回发失败时执行的回调函数

(static) beforeAjaxSuccess(callback)

Description:
  • 注册AJAX回发成功回调函数(返回false则不执行AJAX响应脚本)

Example

页面跳转前弹出系统确认对话框

F.beforeAjaxSuccess(function (data) {
	// 通过返回的字符串,判断是否即将执行页面跳转
	if (data.indexOf('window.location.href=') === 0) {
		if (!window.confirm('是否执行页面跳转?')) {
			return false; // 继续留在当前页面
		}
	}
});
Parameters:
Name Type Description
callback function

AJAX回发成功时执行的回调函数

(static) confirm(options)

Description:
  • 弹出确认对话框

Parameters:
Name Type Description
options Object

初始参数

Properties
Name Type Default Description
target string '_self'

显示对话框的目标位置(可选项为:_self, _parent, _top)

message string ''

消息正文

title string ''

标题文本(留空则使用默认标题)

messageIcon string 'question'

消息图标(可选项为:information, warning, question, error, success)

closable boolean true

是否可关闭

ok function

点击确认按钮时执行的回调函数

cancel function

点击取消按钮时执行的回调函数

(static) cookie(key, value, options)

Description:
  • 新增或者修改Cookie

Parameters:
Name Type Description
key string

value string

options Object

参数

Properties
Name Type Default Description
path string '/'

Cookie保存的网站路径(默认为网站根目录)

expires number

过期时间(单位:天;留空则为会话Cookie,浏览器关闭时自动过期)

(static) doPostBack(options)

Description:
  • 自定义回发请求(F.doPostBack有两种调用形式,这种方式仅在需要设置回调函数和其他参数时使用)

Examples
F.doPostBack({
	url: '/Button/ButtonGroupPress/ButtonGroup_PressChanged',
	params: {
		pressedInfo: getPressedInfo(F.ui.ButtonGroup3)
	}
});
F.doPostBack({
	url: '/Other/FormAjaxComplete/onForm1Submit',
	fields: 'Form1',
	params: {
		key1: 'value1',
		key2: {
			'sub1': 'sub-value1',
			'sub2': 'sub-value2'
		}
	}
	enableAjaxLoading: false, // 不显示回发请求动画
	complete: function (data) {
		// 回发请求结束回调函数
	}
});
Parameters:
Name Type Description
options Object

请求参数

Properties
Name Type Description
url string

发送请求的地址

fields string

发送到服务器的表单字段数据,以逗号分隔多个表单字段(如果是容器,则查找容器内的所有表单字段)

params Object

发送到服务器的数据

complete F_doPostBack_callback

回发请求完成的回调函数

success F_doPostBack_callback

回发请求成功的回调函数

error F_doPostBack_callback

回发请求失败的回调函数

enableAjaxLoading boolean

启用回发提示

ajaxLoadingType string

回发提示的类型(可选项为:default, mask)

ajaxLoadingText string

回发提示的显示文本

ajaxLoadingMaskText string

回发提示的显示文本(ajaxLoadingType=mask)

showAjaxLoadingMaskText string

是否显示回发提示文本(ajaxLoadingType=mask)

(static) doPostBack(url, fieldsopt, paramsopt)

Description:
  • 自定义回发请求(F.doPostBack有两种调用形式,这种方式比较简单,推荐使用)

Examples
function getPressedInfo(btngroup) {
	var result = {
		id: btngroup.id,
		pressed: []
	};
	$.each(btngroup.items, function (index, btn) {
		if (btn.isPressed()) {
			result.pressed.push(btn.getText());
		}
	});
	return F.toJSON(result);
}
F.doPostBack('/Button/ButtonGroupPress/ButtonGroup_PressChanged', {
	pressedInfo: getPressedInfo(F.ui.ButtonGroup3)
});
F.doPostBack('/Other/FormAjaxComplete/onForm1Submit', 'Form1', {
	key1: 'value1',
	key2: {
		'sub1': 'sub-value1',
		'sub2': 'sub-value2'
	}
});
Parameters:
Name Type Attributes Description
url string

发送请求的地址

fields string <optional>

发送到服务器的表单字段数据,以逗号分隔多个表单字段(如果是容器,则查找容器内的所有表单字段)

params Object <optional>

发送到服务器的数据

(static) endsWith(value, source) → {boolean}

Description:
  • 判断一个字符串是否以某个字符串结束

Parameters:
Name Type Description
value string

字符串

source string

源字符串

Returns:

如果是则返回true,否则返回false

Type
boolean

(static) formatDate(format, value) → {Date}

Description:
  • 将日期对象转换为字符串

Example
日期格式规则请参考:F.parseDate
Parameters:
Name Type Description
format string

日期格式化字符串(比如:'yyyy-MM-dd')

value Date

日期对象

Returns:

日期字符串

Type
Date

(static) formatString(form, …param)

Description:
  • 格式化字符串

Parameters:
Name Type Attributes Description
form string

需要格式化的字符串

param string <repeatable>

参数,对应格式字符串中的 {0}, {1}, {2}...

(static) getActiveWindow() → {F.Window}

Description:
  • 获取当前激活的窗体对象

Returns:

窗体对象(其 window 属性表示窗体所在的页面)

Type
F.Window

(static) getHidden(fieldId) → {string}

Description:
  • 获取隐藏字段的值(

Parameters:
Name Type Description
fieldId string

节点ID

Returns:

隐藏字段的值

Type
string

(static) getType(typeName) → {object}

Description:
  • 获取类型字符串对应的类型(例如从字符串 'tabstrip' 获取类型 F.TabStrip)

Parameters:
Name Type Description
typeName string

类型字符串

Returns:

类型

Type
object

(static) hasHScrollbar(el) → {boolean}

Description:
  • 是否存在水平滚动条

Parameters:
Name Type Description
el jQuery

节点

Returns:

是否存在水平滚动条

Type
boolean

(static) hasVScrollbar(el) → {boolean}

Description:
  • 是否存在垂直滚动条

Parameters:
Name Type Description
el jQuery

节点

Returns:

是否存在水平滚动条

Type
boolean

(static) htmlDecode(value) → {string}

Description:
  • HTML解码

Parameters:
Name Type Description
value string

输入值

Returns:

解码后的值

Type
string

(static) htmlEncode(value) → {string}

Description:
  • HTML编码

Parameters:
Name Type Description
value string

输入值

Returns:

编码后的值

Type
string

(static) initTreeTabStrip(treeMenu, mainTabStrip, options)

Description:
  • 初始化官网示例框架(左侧树与右侧选项卡面板交互)

Example
F.initTreeTabStrip(F.ui.Tree1, F.ui.TabStrip1, {
    maxTabCount: 10,
    maxTabMessage: '请先关闭一些选项卡(最多允许打开 10 个)!'
});
Parameters:
Name Type Description
treeMenu F.Tree

左侧树实例

mainTabStrip F.TabStrip

选项卡面板实例

options Object

可选参数

Properties
Name Type Description
updateHash boolean

切换Tab时,是否更新地址栏Hash值(默认值:true)

refreshWhenExist boolean

添加选项卡时,如果选项卡已经存在,是否刷新内部IFrame(默认值:false)

refreshWhenTabChange boolean

切换选项卡时,是否刷新内部IFrame(默认值:false)

maxTabCount number

最大允许打开的选项卡数量

maxTabMessage string

超过最大允许打开选项卡数量时的提示信息

beforeNodeClick F_initTreeTabStrip_beforeNodeClick

节点点击事件之前执行(返回false则不执行点击事件)

beforeTabAdd F_initTreeTabStrip_beforeTabAdd

添加选项卡之前执行(返回false则不添加选项卡)

singleTabId string

单标签页模式下的标签页标识符(留空即为多标签页模式)

moveToEnd boolean

将选项卡移到尾部(如果选项卡已存在,则不改变位置,默认值:false)

(static) isARR(value) → {boolean}

Description:
  • 测试对象是否为数组

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isBOO(value) → {boolean}

Description:
  • 测试对象是否为布尔型

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isDAT(value) → {boolean}

Description:
  • 测试对象是否为日期对象

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isELE(value) → {boolean}

Description:
  • 测试对象是否为DOM节点元素

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isEMP(value) → {boolean}

Description:
  • 测试对象是否为空(undefined, null 或者 空字符串)

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isEOBJ(value) → {boolean}

Description:
  • 测试对象是否为空对象(不包含任何属性)

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isFUN(value) → {boolean}

Description:
  • 测试对象是否为函数

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isNAN(value) → {boolean}

Description:
  • 测试对象是否为NaN

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isNUM(value) → {boolean}

Description:
  • 测试对象是否为数字

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isPOBJ(value) → {boolean}

Description:
  • 测试对象是否为纯粹对象(通过 {} 或者 new Object 创建的对象)

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isSTR(value) → {boolean}

Description:
  • 测试对象是否为字符串

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) isUND(value) → {boolean}

Description:
  • 测试对象是否为undefined或者null

Parameters:
Name Type Description
value object

需要测试的对象

Returns:

测试结果

Type
boolean

(static) noAnimation(fn)

Description:
  • 回调函数中不进行动画操作

Parameters:
Name Type Description
fn function

回调函数

(static) noEvent(fn)

Description:
  • 回调函数中不触发事件

Parameters:
Name Type Description
fn function

回调函数

(static) noLayout(fn)

Description:
  • 回调函数中不进行布局操作

Parameters:
Name Type Description
fn function

回调函数

(static) noValidate(fn)

Description:
  • 回调函数中不验证表单字段

Parameters:
Name Type Description
fn function

回调函数

(static) notify(options)

Description:
  • 弹出通知对话框

Parameters:
Name Type Description
options Object

初始参数

Properties
Name Type Default Description
target string '_self'

显示对话框的目标位置(可选项为:_self, _parent, _top)

message string ''

消息正文

title string ''

标题文本(留空则使用默认标题)

messageIcon string 'question'

消息图标(可选项为:information, warning, question, error, success)

closable boolean true

是否可关闭

hide function

对话框隐藏时执行的回调函数

modal boolean false

是否为模式对话框

draggable boolean true

是否可拖动

header boolean true

是否显示标题栏

showLoading boolean false

是否显示正在加载图标

positionX string 'right'

横坐标的位置(可选项为:left, center, right)

positionY string 'bottom'

纵坐标的位置(可选项为:top, center, bottom)

displayMilliseconds number 0

自动消失之前显示的秒数(0-不消失)

(static) parseDate(format, value) → {Date}

Description:
  • 将字符串转换为日期对象

Example
d     -   月中的某一天,一位数的日期没有前导零。
dd    -   月中的某一天,一位数的日期有一个前导零。
ddd   -   周中某天的缩写名称。
dddd  -   周中某天的完整名称。
M     -   月份数字,一位数的月份没有前导零。
MM    -   月份数字,一位数的月份有一个前导零。
MMM   -   月份的缩写名称。
MMMM  -   月份的完整名称。
yy    -   不包含纪元的年份。
yyyy  -   包括纪元的四位数的年份。
h     -   12小时制的小时,一位数的小时数没有前导零。
hh    -   12小时制的小时,一位数的小时数有前导零。
H     -   24小时制的小时,一位数的小时数没有前导零。
HH    -   24小时制的小时,一位数的小时数有前导零。
m     -   分钟,一位数的分钟数没有前导零。
mm    -   分钟,一位数的分钟数有一个前导零。
s     -   秒,一位数的秒数没有前导零。
ss    -   秒,一位数的秒数有一个前导零。
Parameters:
Name Type Description
format string

日期格式化字符串(比如:'yyyy-MM-dd')

value string

日期字符串

Returns:

日期对象

Type
Date

(static) parseJSON(value) → {Object}

Description:
  • 将JSON字符串转换为JavaScript对象

Parameters:
Name Type Description
value string

JSON字符串

Returns:

JavaScript对象

Type
Object

(static) progressHtml(value, options)

Description:
  • 生成进度条HTML片段

Parameters:
Name Type Description
value Object

初始值

options Object

初始参数

Properties
Name Type Default Description
height number

进度条的高度

textVisible boolean false

是否显示进度条文本

textInside boolean false

是否将进度条文本显示在进度条内部

(static) prompt(options)

Description:
  • 弹出输入对话框

Parameters:
Name Type Description
options Object

初始参数

Properties
Name Type Default Description
target string '_self'

显示对话框的目标位置(可选项为:_self, _parent, _top)

message string ''

消息正文

title string ''

标题文本(留空则使用默认标题)

messageIcon string 'question'

消息图标(可选项为:information, warning, question, error, success)

closable boolean true

是否可关闭

ok function

点击确认按钮时执行的回调函数(回调函数的第一个参数为用户输入值)

cancel function

点击取消按钮时执行的回调函数(回调函数的第一个参数为用户输入值)

multiLine boolean false

是否显示多行输入框

multiLineHeight number

多行输入框的高度

defaultValue string ''

输入框的缺省值

required boolean false

输入框是否为必填项

(static) queryString(name, urlopt) → {string}

Description:
  • 获取URL中的参数值

Parameters:
Name Type Attributes Description
name string

参数名

url string <optional>

在指定URL中查找(留空在当前页面URL中查找)

Returns:

URL中参数名对应的值

Type
string

(static) rateEvents(container, callback)

Description:
  • 注册评分事件

Parameters:
Name Type Description
container jQuery

评分容器

callback F_rateEvents_callback

评分改变的回调函数

(static) rateHtml(value, options)

Description:
  • 生成评分HTML片段

Parameters:
Name Type Description
value Object

初始值

options Object

初始参数

Properties
Name Type Default Description
allowClear boolean true

是否允许通过点击来清除评分

allowHalf boolean false

是否允许半星评分

iconFont string ''

评分图标字体

iconFontCls string ''

自定义评分图标字体的样式类

character string ''

自定义评分字符

count number 5

评分图标的个数

readonly boolean false

是否只读

textVisible boolean false

是否显示评分文本

textRenderer function

自定义评分文本的渲染函数

(static) ready(callback)

Description:
  • 注册页面渲染完毕回调函数

Parameters:
Name Type Description
callback function

页面加载完毕时执行的回调函数

(static) removeCommas(string) → {string}

Description:
  • 移除千分位分隔符

Parameters:
Name Type Description
string string

数字

Returns:

不包含千分位分隔符的字符串

Type
string

(static) removeCookie(key, options)

Description:
  • 删除Cookie

Parameters:
Name Type Description
key string

options Object

参数

Properties
Name Type Default Description
path string '/'

Cookie保存的网站路径(默认为网站根目录)

(static) removeDotSeparator(string, dotSeparator, commaSeparator) → {string}

Description:
  • 移除小数分隔符

Parameters:
Name Type Description
string string

数字

dotSeparator string

小数分隔符

commaSeparator string

千分位分隔符(如果为undefined,则表示输入的数字不包含千分位分隔符)

Returns:

不包含小数分隔符的字符串

Type
string

(static) removeHidden(fieldId)

Description:
  • 删除隐藏字段(

Parameters:
Name Type Description
fieldId string

节点ID

(static) reset(containerId)

Description:
  • 重置容器内的全部表单字段

Parameters:
Name Type Description
containerId string

容器标识符(留空则重置页面上的全部表单字段)

(static) setHidden(fieldId, fieldValue)

Description:
  • 设置隐藏字段的值(

Parameters:
Name Type Description
fieldId string

节点ID

fieldValue string

设置的值

(static) smartLayout(fn)

Description:
  • 回调函数执行完毕后再进行布局操作

Parameters:
Name Type Description
fn function

回调函数

(static) startsWith(value, source) → {boolean}

Description:
  • 判断一个字符串是否以某个字符串开头

Parameters:
Name Type Description
value string

字符串

source string

源字符串

Returns:

如果是则返回true,否则返回false

Type
boolean

(static) toJSON(value) → {string}

Description:
  • 将JavaScript对象转换为JSON字符串

Parameters:
Name Type Description
value Object

JavaScript对象

Returns:

JSON字符串

Type
string

(static) ui(options) → {F.Component}

Description:
  • 创建控件实例

Parameters:
Name Type Description
options object

初始参数

Returns:

控件实例

Type
F.Component

(static) urlDecode(url) → {string}

Description:
  • URL解码

Parameters:
Name Type Description
url string

输入值

Returns:

解码后的值

Type
string

(static) urlEncode(url) → {string}

Description:
  • URL编码

Parameters:
Name Type Description
url string

输入值

Returns:

编码后的值

Type
string

(static) validateForm(form, target, showMessageBox, messageBoxPlain) → {object}

Description:
  • 验证单个表单

Parameters:
Name Type Default Description
form string

需要验证的表单标识符

target string '_self'

验证失败时显示对话框的目标位置(可选项为:_self, _parent, _top)

showMessageBox boolean true

验证失败时是否显示对话框

messageBoxPlain boolean false

是否简单对话框

Returns:

验证结果(数组:[是否验证通过,第一个验证失败的表单字段标识符])

Type
object

(static) validateForms(forms, target, showMessageBox, messageBoxPlain) → {object}

Description:
  • 验证多个表单

Parameters:
Name Type Default Description
forms Array.<string>

需要验证的表单标识符数组

target string '_self'

验证失败时显示对话框的目标位置(可选项为:_self, _parent, _top)

showMessageBox boolean true

验证失败时是否显示对话框

messageBoxPlain boolean false

是否简单对话框

Returns:

验证结果(数组:[是否验证通过,第一个验证失败的表单字段标识符])

Type
object

(static) windowResize(fn)

Description:
  • 注册页面大小改变事件(延迟 500 毫秒触发)

Parameters:
Name Type Description
fn function

回调函数