Title: creation of datagrid not working Post by: gib65 on March 06, 2017, 08:53:01 AM Hello,
I'm trying the following code to create a data grid, but it doesn't seem to be working: Code: <head> I get an error in the Chrome console that says: "$(...).datagrid is not a function." I get that error from this line: var dg = $('#EasyUI_DataGrid').datagrid(); I believe all my references in the head are correct. Can anyone see what I'm doing wrong? Thanks. Title: Re: creation of datagrid not working Post by: Max Lamda on March 07, 2017, 08:06:21 AM You should define "data" outside the ready function and please enclose the whole document in <html> and </html>
Title: Re: creation of datagrid not working Post by: gib65 on March 07, 2017, 10:12:41 AM Thanks Max,
Placing the initialization of data outside the ready function works when I'm just building the page in Notepad. You can see it at http://www.shahspace.com/easyui/index.html But in my Visual Studio 2015 application, it still gives me the message: Uncaught TypeError: $(...).datagrid is not a function. And no grid shows up on the page. Is it possible this might happen if we have a conflict of JQuery references? I know the application uses JQuery (can't find the reference to it) and the references: http://code.jquery.com/jquery-1.7.1.min.js http://www.jeasyui.com/easyui/jquery.easyui.min.js ...seem to also reference JQuery. Could this be causing a clash? Title: Re: creation of datagrid not working Post by: gib65 on March 07, 2017, 10:23:56 AM Follow up...
Going a few steps further, I tried putting the references in the actual page with the grid (as opposed to the master page). <-- That worked! I still get errors in the Chrome console though. Any idea why these might be happening: (http://www.shahspace.com/easyui/errors putting refs in page.png) Title: Re: creation of datagrid not working Post by: Pierre on March 07, 2017, 11:41:04 PM Thanks Max, Your sample works without any error. You must have both (jQuery and EasyUI) so your code is correct. You need to take a look at your app.js, line 4664 for possible errors.Placing the initialization of data outside the ready function works when I'm just building the page in Notepad. You can see it at http://www.shahspace.com/easyui/index.html But in my Visual Studio 2015 application, it still gives me the message: Uncaught TypeError: $(...).datagrid is not a function. And no grid shows up on the page. Is it possible this might happen if we have a conflict of JQuery references? I know the application uses JQuery (can't find the reference to it) and the references: http://code.jquery.com/jquery-1.7.1.min.js http://www.jeasyui.com/easyui/jquery.easyui.min.js ...seem to also reference JQuery. Could this be causing a clash? Title: Re: creation of datagrid not working Post by: gib65 on March 08, 2017, 09:11:11 AM Thanks Pierre,
I fixed the problem by commenting out the JQuery reference for the grid like so: Code: <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/default/easyui.css"> Since we already have JQuery integrated into the application globally, there is no need to reference another version of it. I think what was happening was that since I had the reference to JQuery 1.7.1 in the page with the grid, it was overriding our other JQuery reference, which is a later version. It therefore hit the line $.validator.setDefaults(defaultOptions); on line 4664 of app.js and didn't recognize "validator" which is not defined in 1.7.1. |