Html5 Grid

Set the selectionmode property of the jqxGrid. Author: http://jqwidgets.com

by Manu Vashishtha

HTML

<script src="https://jqwidgets.com/public/jqwidgets/jqx-all.js"></script>
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.energyblue.css">
<script src="https://jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/generatedata.js"></script>
<div id="jqxgrid"></div>
<div style="margin-top: 20px;">
    <div style="clear: both; font-family: Verdana, Geneva, 'DejaVu Sans', sans-serif; font-size: 12px;">
        <div style="float: left;">
            <div>
                <input value="100" style="width: 50px;" maxlength="4" id="rowindexinput2" type="text" />
                <input id="scrolltobutton" type="button" value="Scroll to Row" />
            </div>
            <div style="margin-top: 10px;">
                <input value="0" style="width: 50px;" maxlength="4" id="rowindexinput" type="text" />
                <input id="selectrowbutton" type="button" value="Select Row" />
                <input id="clearselectionbutton" type="button" value="Clear Selection" />
            </div>
            <div style="margin-top: 10px;" id="enablehover">Enable Hover</div>
            <div style="margin-top: 10px;">Selection Mode:
                <div style="margin-top: 5px;" id="enableselection"></div>
                <div style="margin-top: 10px; font-size: 12px; font-family: Verdana, Geneva, 'DejaVu Sans', sans-serif;">Selection Modes:
                    <ul>
                        <li>"none" - disables the selection. Selection is possible only through the API.</li>
                        <li>"singlerow" - full row selection. Each click changes the selected row.</li>
                        <li>"multiplerows" - each click selects a new row. Click on a selected row unselects it.</li>
                        <li>"multiplerowsextended" - users can select multiple rows with drag and drop or
                            <br />by clicking on rows while holding Ctrl...

JavaScript

var data = generatedata(200);
  var source = {
      localdata: data,
      datafields: [{
          name: 'id',
          type: 'number'
      }, {
          name: 'firstname',
          type: 'string'
      }, {
          name: 'lastname',
          type: 'string'
      }, {
          name: 'productname',
          type: 'string'
      }, {
          name: 'quantity',
          type: 'number'
      }, {
          name: 'price',
          type: 'number'
      }, {
          name: 'total',
          type: 'number'
      }],
      datatype: "array"
  };
  var dataAdapter = new $.jqx.dataAdapter(source);
  // initialize jqxGrid
  $("#jqxgrid").jqxGrid({
      theme: 'energyblue',
      width: 500,
      height: 350,
      theme: 'energyblue',
      source: dataAdapter,
      columns: [{
          text: 'Id',
          datafield: 'id',
          width: 50
      }, {
          text: 'First Name',
          datafield: 'firstname',
          width: 100
      }, {
          text: 'Last Name',
          datafield: 'lastname',
          width: 100
      }, {
          text: 'Product',
          datafield: 'productname',
          width: 180
      }, {
          text: 'Quantity',
          datafield: 'quantity',
          width: 80,
          cellsalign: 'right'
      }, {
          text: 'Unit Price',
          datafield: 'price',
          width: 90,
          cellsalign: 'right',
          cellsformat: 'c2'
      }, {
          text: 'Total',
          datafield: 'total',
          width: 100,
          cellsalign: 'right',
          cellsformat: 'c2'
      }]
  });
  // initialize buttons and checkboxes.
  $("#selectrowbutton").jqxButton({
      theme: 'energyblue'
  });
  $("#scrolltobutton").jqxButton({
      theme: 'energyblue'
  });
  $("#clearselectionbutton").jqxButton({
      theme: 'energyblue'
  });
  $("#enableselection").jqxDropDownList({
      theme: 'energyblue',
      autoDropDownHeight: true,
      dropDownWidth: 230,
      width: 120,
      height: 25,
...