How to design combo grids using jQuery EasyUI?


jQuery EasyUI is a powerful and user-friendly JavaScript library that can be used to create various UI components, including combo grids. Combo grids are a combination of drop-down lists and data grids, which allow users to select data from a list with a grid-like interface.

In this article, we will go over the steps to design combo grids using jQuery EasyUI.

Example

<!DOCTYPE html>
<html>
<head>
   <meta charset="UTF-8">
   <title>Combo Grids with jQuery EasyUI</title>
   <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
   <link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/default/easyui.css">
   <script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
   <style>
      #combo-grid {
         height: 300px;
         width: 500px;
      }
   </style>
   <script>
      $(function() {
         $.ajax({
            url: 'https://reqres.in/api/users?page=2',
            type: 'GET',
            success: function(data) {
               $('#combo-grid').combogrid({
                  panelWidth: 500,
                  idField: 'id',
                  textField: 'email',
                  data: data.data,
                  columns: [[
                     {field:'id',title:'ID',width:50},
                     {field:'email',title:'Email',width:200},
                     {field:'first_name',title:'First Name',width:100,align:'right'},
                     {field:'last_name',title:'Last Name',width:100,align:'right'}
                  ]],
                  onSelect: function(rowIndex, rowData) {
                     console.log(rowData);
                  }
               });
            }
         });
      });
   </script>
</head>
<body>
   <h1>Combo Grids with jQuery EasyUI</h1>
   <p>This example shows how to create a combo grid using jQuery EasyUI.</p>
   <div id="combo-grid"></div>
</body>
</html>

Explanation

  • The code sets up a combo grid using the jQuery EasyUI library. The combo grid is a drop-down list with a grid-like interface, displaying data from a JSON file.

  • The grid has four columns: ID, Name, Price, and Quantity. When an item is selected from the grid, its data is logged to the console. The code imports the necessary JavaScript and CSS files from the EasyUI library and sets up some basic styling for the grid.

Conclusion

Designing combo grids using jQuery EasyUI is a simple and effective way to create user-friendly interfaces for selecting items from a list. By following the steps outlined in this article, you can create a customized combo grid that suits your needs. With jQuery EasyUI, you can add features such as styling, event listeners, and data sources to your combo grid, making it a powerful tool for web design.

Updated on: 17-Apr-2023

215 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements