Title: Grid and texktboxes Post by: jonbang on February 29, 2016, 03:53:19 PM I am creating a small web-page for my CD/DVD-records. just for learning how things work. Getting the data in the grid is no problen, neither getting the data in the webpage. I have a database called cdarkiv. And two tables. OIne for info about the artist and the album, another table for the songs. Whar i would like to do is put the info from artist/album-table direct to the page, and the songs from that album to the grid. Is that possible, or i know it is, but how to do that?
As an alternativ i would like two grids. One for album/artist and one for the songs. When a line in artist/album-grid is marked, the songs will show on the othergrid.... And if i could use the same setup for adding and deleting as well....Anyone? Title: Re: Grid and texktboxes Post by: stworthy on March 02, 2016, 01:02:13 AM Here is the simple way for two grid solution. When selecting the 'artist' datagrid, the 'onSelect' event fires. You will be able to get the selected row and reload the 'songs' grid data. The code looks like this:
Code: $('#artist').datagrid({ Title: Re: Grid and texktboxes Post by: jonbang on March 02, 2016, 07:07:43 AM In the code below, where to put the example you gave me? This is relative new to me...:-)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="keywords" content="jquery,ui,easy,easyui,web"> <meta name="description" content="easyui help you build your web page easily!"> <title>Build CRUD DataGrid with jQuery EasyUI - jQuery EasyUI Demo</title> <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/icon.css"> <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/demo/demo.css"> <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.min.js"></script> <script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script> <script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.edatagrid.js"></script> <script type="text/javascript"> $(function(){ $('#dg').edatagrid({ url: 'get_users.php', saveUrl: 'save_user.php', updateUrl: 'update_user.php', destroyUrl: 'destroy_user.php' }); }); </script> </head> <body> <h2>CRUD DataGrid</h2> <div class="demo-info" style="margin-bottom:10px"> <div class="demo-tip icon-tip"> </div> <div>Double click the rad to begin editing.</div> </div> <table id="dg" title="My Users" style="width:700px;height:250px" toolbar="#toolbar" pagination="true" idField="id" rownumbers="true" fitColumns="true" singleSelect="true"> <thead> <tr> <th field="actor_id" width="50" editor="{type:'validatebox',options:{required:true}}">First Name</th> <th field="first_name" width="50" editor="{type:'validatebox',options:{required:true}}">Last Name</th> <th field="last_name" width="50" editor="text">Phone</th> <th field="last_update" width="50" editor="{type:'validatebox',options:{validType:'email'}}">Email</th> </tr> </thead> </table> <div id="toolbar"> <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="javascript:$('#dg').edatagrid('addRow')">New</a> <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="javascript:$('#dg').edatagrid('destroyRow')">Destroy</a> <a href="#" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="javascript:$('#dg').edatagrid('saveRow')">Save</a> <a href="#" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="javascript:$('#dg').edatagrid('cancelRow')">Cancel</a> </div> </body> </html> Title: Re: Grid and texktboxes Post by: stworthy on March 02, 2016, 08:01:17 AM Please refer to the code below:
Code: <table id="dg" title="My Users" style="width:700px;height:250px" Title: Re: Grid and texktboxes Post by: jonbang on March 03, 2016, 02:52:22 PM Ok, this is what i get up:
The script is used twice, and the same query for the same database. Is that supposed to be right, or shuold there be another query in the second grid? I have here used an example from the sakila database, a view called actor_infoT\My plan is to get the row called film_info to be displayed in the second grid. The sql returns the actor_id, first_name and last_name in grid1, and film_info in grid2. But as you can see, only the rows in grid1 are displayed....What am i doing wrong? Title: Re: Grid and texktboxes Post by: stworthy on March 03, 2016, 08:28:40 PM There are two issues existing in your page.
1. The event name should be 'onSelect' not 'onselect'. 2. The 'url' property value is required in your 'dg-songs' datagrid. Please correct them and try again. Title: Re: Grid and texktboxes Post by: jonbang on March 04, 2016, 02:49:46 AM We are talking about the url-property in the table for dg-songs? What is this url supposed to point to?
|