• Stars
    star
    731
  • Rank 61,995 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple style and powerful selector, including ajax remote data, autocomplete, pagination, tags, i18n and keyboard navigation features
SelectPage

SelectPage

A simple style and powerful selection jQuery plugin, including ajax remote data, autocomplete, pagination, tags, i18n and keyboard navigation features

996.icu




Examples and Documentation

Explorer on

简体中文文档

The Vuejs version: v-selectpage

SelectPage

Features

  • a jQuery(1.x) plugin
  • highly customized
  • compatible with no UI framework of the program, but it is recommended to use at least normalize.css
  • quick search item by input autocomplete
  • use keybord to quick navigate
  • multiple select by tag form
  • screen edges handle
  • custom content render
  • i18n supports, provide 6 languages
  • server side data supports

Browsers support

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Opera
Opera
IE8, IE9, IE10, IE11, Edge Firefox 18+ Chrome 49+ Safari 10+ Opera 36+

Plugin Preview

Multiple Selection with Tags form

SelectPage1

Regular select mode ( single selection )

SelectPage

List only ( pagination bar close, disable typing to quick search, select only )

SelectPageList

Installation

Download SelectPage plugin zip file by last release, or click me to download SelectPage

or use NPM

npm install selectpage

Usage

As you can see in the Demo Page, you will need to include:

  • jQuery library (1.10.2+), untest on jquery2.x & 3.x
  • The JavaScript file selectpage.js (or its minified version selectpage.min.js)
  • The css file selectpage.css

Including files

<!-- jQuery library -->
<script type="text/javascript" src="jquery.min.js" ></script>

<link rel="stylesheet" href="selectpage.css" type="text/css">
<script type="text/javascript" src="selectpage.js" ></script>

HTML input element set

the SelectPage plugin just need put a input tag in the page

<input type="text" id="selectpage" >

Javascript init plugin

// defined a array (the server side returned data format was same like that)
// Array[{Object},{...}]
var data = [
  {id: 1, name: 'Chicago Bulls', desc: '芝加哥公牛' },
  {id: 2, name: 'Cleveland Cavaliers', desc: '克里夫兰骑士' },
  {id: 3, name: 'Detroit Pistons', desc: '底特律活塞' },
  {id: 4, name: 'Indiana Pacers', desc: '印第安纳步行者' }
]
// init SelectPage
$('#selectpage').selectPage({
  showField : 'desc',
  keyField : 'id',
  data : data
})

Stargazers over time

Stargazers over time

Options

The plugin initialize options

data

  • type: string | object
  • default: undefined

data source (string:ajax search URL | object:JSON format array)

// serverside request url address
$('#selectpage').selectPage({
  data: 'https://some-site/some-route'
})

// JSON format array
var data = [{a:1,b:2,c:3},{...}]
$('#selectpage').selectPage({
  data: data
})

lang

  • type: string
  • default: 'cn'

plugin language

code language
cn chinese
en english
de german
es spanish
ja japanse
pt-br Brazilian Portuguese

multiple

  • type: boolean
  • default: false

whether it is multi-select mode(use tags mode)

pagination

  • type: boolean
  • default: true

paging or not

listSize

  • type: number
  • default: 10

the list shows the number of items, and the other items are displayed in a scroll bar,it only work on pagination : false

multipleControlbar

  • type: boolean
  • default: true

whether to enable the multi-select mode control button area,only work on multiple: true

maxSelectLimit

  • type: number
  • default: 0

maximum number of selections in multi-select mode,0 is unlimited

selectToCloseList

  • type: boolean
  • default: true

is close list after item select,it only work on multiple:true

initRecord

  • type: string
  • default: undefined

the initial value of the plugin, The value will match the option.keyField field, and if it matches, it will be automatically selected and highlighted

dbTable

  • type: string
  • default: 'tbl'

use this parameter to set the corresponding data table name in server side(ajax) mode

keyField

  • type: string
  • default: 'id'

value field, usually the contents of the field will be automatically saved in the hidden domain

showField

  • type: string
  • default: 'name'

the result is used to display the name of the attribute

searchField

  • type: string
  • default: undefined

query field, set server side query field when data source is server side mode, if not set default use of option.showField

andOr

  • type: string
  • default: 'AND'

multiple keywords search type ('AND' or 'OR')

orderBy

  • type: string[]
  • default: undefined

result data sort type, default use showField specified field

$('#selectpage').selectPage({
  ...
  orderBy : ['id desc'] // use id field sort desc
})

pageSize

  • type: number
  • default: 10

the number of records per page

params

  • type: function (): object
    • return object
  • default: undefined

send request params for server side data source(ajax)

$('#selectpage').selectPage({
  ...
  params : function() {
    return {
      name: 'aa',
      sex: 1
    }
  }
})

formatItem

  • type: function (data: object): string
    • data object row data object format
    • return string
  • default: undefined

list item display content formatting

$('#selectpage').selectPage({
  ...
  formatItem : function(data) {
    return data.a + '(' + data.b + ')'
  }
})

focusDropList

  • type: boolean
  • default: true

when input box get focus,drop the list

autoSelectFirst

  • type: boolean
  • default: true

whether to automatically select the first item in the list (enter the keyword query mode, use the mouse directly does not trigger)

autoFillResult

  • type: boolean
  • default: true

whether to automatically fill the content, if the list item is highlighted, in the focus away from the control, automatically set the item for the selected content

noResultClean

  • type: boolean
  • default: true

enter the keyword to query and no item match,when focus leave plugin,whether to clear enter keywords

selectOnly

  • type: boolean
  • default: false

select only mode,the input box can not enter any word

inputDelay

  • type: number
  • default: 0.5(second)

enter the keyword query delay, work on server side(ajax) mode

eSelect

  • type: function (data: object|object[]): void
    • data object | array selected row or rows data(json)
  • default: undefined

item selected callback

$('#selectpage').selectPage({
  ...
  eSelect : function(data) {
    console.log(data)
  }
})

eOpen

  • type: function (self: object): void
    • self object plugin inner object
  • default: undefined

before show up result list callback

$('#selectpage').selectPage({
  ...
  eOpen : function(self) {
    console.log(self)
  }
})

eAjaxSuccess

  • type: function (data: object): object
    • data object server side return data(json)
    • return object convert to SelectPage required data format
  • default: undefined

in server side mode, this is the callback function when request success, the role of the callback is used to custom processing of the return data

server side return data for example

{
  "values": {
    "gridResult": {
      "pageSize": 10,
      "pageNumber": 1,
      "totalRow": 11,
      "totalPage": 2,
      "listData": [
        { "name": "name1", "id": "1" },
        { "name": "name2", "id": "2" },
        { ... }
      ]
    }
  }
}

eAjaxSuccess required data format

{
  list: object[],  // rows data
  totalRow: number // total record count number
}

then eAjaxSuccess code for example below

$('#selectpage').selectPage({
  ...
  data: 'https://some-site/some-route',
  eAjaxSuccess : function(data) {
    var dataNode = data.values.gridResult
    return {
      list : dataNode.listData,
      totalRow : dataNode.totalRow
    }
  }
})

eTagRemove

  • type: function (tags: object[]): void
    • tags object[] removed tags raw data
  • default: undefined

this callback function is used to close tag, when multiple : true

$('#selectpage').selectPage({
  ...
  eTagRemove : function(tags) {
    console.log(tags)
  }
})

API

selectPageClear

  • selectPageClear(): void

clear all select items

$('#selectpage').selectPageClear()

selectPageRefresh

  • selectPageRefresh(): void

refresh plugin selected items info

$('#selectpage').val(20) // modify selected by id used javascript
$('#selectpage').selectPageRefresh() // refresh selection item info

selectPageData

  • selectPageData(data: object): void
    • data array new data, the data format is same to plugin data source

change plugin data source,only work on json data source mode

var newdata = [
  { a: 1, b: 11, c: 111 },
  { a: 2, b: 22, c: 222 },
  { ... }
]
$('#selectpage').selectPageData(newdata)

selectPageDisabled

  • selectPageDisabled(status?: boolean): void|boolean
    • status boolean(optional) set disabled stauts. true to disabled, false to enabled
    • return boolean(optional) plugin disabled status

get plugin disabled status or set plugin status to disabled / enabled

// get plugin disabled stuats
if($('#selectpage').selectPageDisabled()) {
  // set plugin to enabled
  $('#selectpage').selectPageDisabled(false)
}

selectPageText

  • selectPageText(): string
    • return string selected items string content

get plugin selected items text

alert($('#selectpage').selectPageText())

selectPageSelectedData

  • selectPageSelectedData(): object[]
    • return object[] selected items raw datas

get selected items raw data

console.log($('#selectpage').selectPageSelectedData())

License

FOSSA Status

More Repositories

1

v-region

提供 5 种应用形式的 4 级行政区划选择器 A simple region cascade selector, provide 4 levels Chinese administrative division data
JavaScript
866
star
2

SelectMenu

Simple, easily and diversity menu solution
JavaScript
297
star
3

v-uploader

A Vue2 plugin make files upload simple and easier, single file upload with image preview, multiple upload with drag and drop
Vue
238
star
4

v-selectpage

SelectPage for Vue2, list or table view of pagination, use tags for multiple selection, i18n and server side resources supports
JavaScript
236
star
5

v-selectmenu

SelectMenu for Vuejs, A simple, easier and highly customized menu solution
JavaScript
187
star
6

bDialog

Extend the Bootstrap Modal features, making dialog more functions and easier to use, dialog type including modal, alert, mask and toast types
JavaScript
175
star
7

v-dialogs

A simple and clean instructional dialog plugin for Vue2, dialog type including Modal, Alert, Mask and Toast
JavaScript
128
star
8

bTabs

A jQuery plugin open pages in tab, based on Bootstrap2,3
JavaScript
127
star
9

frontend-develops-skill-summary

Development experience with javascript, jQuery, Vuejs, Wechat MiniProgram and so on
122
star
10

bPage

Based on bootstrap style, static page jump can also be asynchronous page processing pagination plugin
JavaScript
102
star
11

v-page

A simple and useful pagination component for vue2 and vue3
JavaScript
90
star
12

v-suggest

A Vue2 plugin for input content suggestions, support using keyboard to navigate and quick pick, it make use experience like search engine input element
JavaScript
75
star
13

v-gallery

A Vue2 plugin for images show in gallery or carousel
Vue
62
star
14

vuepress-login

Add user authorization for VuePress
JavaScript
41
star
15

v-ztree

A simple tree for Vue2, support single or multiple(check) select tree, and support server side data
Vue
36
star
16

v-playback

A Vue2 plugin to make video play easier
Vue
18
star
17

v-dropdown

A dropdown container layer plugin for vue
JavaScript
15
star
18

vue-plugins

vue plugins development environment
JavaScript
11
star
19

v-tablegrid

A simpler to use and practical datatable
Vue
9
star
20

TerryZ.github.io

Main Page
HTML
5
star
21

grid-improve

grid-improve
HTML
1
star