EasyUI Forum
April 19, 2024, 04:29:04 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Datagrid delete record and reload problem  (Read 11504 times)
jega
Full Member
***
Posts: 190


View Profile
« on: February 14, 2017, 03:19:03 AM »

Hi.

I have a datagrid with some records. When i delete a record, and reload it, the record is still in the grid, but deleted from db. close the page and open it Again, the record is not in grid, as espected.

I have to set the browser settings to "Always get the site" (default in browser is Automatic), to remove the record from the grid, on reload, after delete.

What can i do Huh

Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: February 14, 2017, 07:47:27 AM »

After removing the record from the database, please call 'reload' or 'load' method to refresh the datagrid rows. Please look at this example http://www.jeasyui.com/demo/main/index.php?plugin=Application&theme=default&dir=ltr&pitem=Basic%20CRUD
Logged
jega
Full Member
***
Posts: 190


View Profile
« Reply #2 on: February 14, 2017, 01:14:03 PM »

Yes i know how to do it. Here my code.

The treegrid is presenting files in a folder.

Mark a row, push delete. asp code deleting the file, and if ok, reload the treegrid

   function deleteFile(){
       var row = $('#fileBrowser').treegrid('getSelected');
       if (row){
           $.messager.confirm('Verify','Er du sikker på du vil slette '+row.name+' ?',function(r){
               if (r){
                   $.post('data_files.asp?st=deletefile',{fn:row.path},function(data,status,xhr){
                      if (data == 'ok'){
                         $('#fileBrowser').treegrid('reload');
                      }
                   });
               }
           });
       }
   }

BUT, the row remains in treegrid. When reload site, the treegrid shows the remaining rows, as espected.
If the browser settings is "Automatic" load site, it takes the site from cache, and the treegrid reload doesn't Work, but if i change the browser settings to "Always load site", the reload treegrid Works fine.


Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: February 14, 2017, 08:46:52 PM »

To remove a treegrid row, please call 'remove' method instead.
Code:
$('#fileBrowser').treegrid('remove',row.id);
Logged
jega
Full Member
***
Posts: 190


View Profile
« Reply #4 on: February 15, 2017, 01:15:00 AM »

I can see that method, but the same happens on the datagrid. All my users have to change browser settings.

Add or delete a row to the mysql and reload datagrid, only Works when the browser is setup to load page "On every visit"
Logged
jega
Full Member
***
Posts: 190


View Profile
« Reply #5 on: February 15, 2017, 01:19:38 AM »

It's a cache problem.

Tried to add a row. Row just fine in mysql, but no row showed on reload datagrid.

Closing browser, and open Again, still no row. Change settings in browser to get page every time, and the row is now showed.
Logged
jega
Full Member
***
Posts: 190


View Profile
« Reply #6 on: May 09, 2017, 11:16:04 PM »

Weeee.

Solved the problem

Had this code

<table id="dgAddressList" class="easyui-datagrid" title="PersonListe" style="width:auto;height:auto" data-options="
            url:'getfromdb.asp?st=personlist&ct=true',
            rownumbers:false,
            checkOnSelect:true,
            method:'get',
            pagination:true,
            singleSelect:false,
            idField:'cpr',
            toolbar:'#toolbarAddressList'">


With this code, adding/removing a line to database and using $('#dgAddressList').datagrid('reload'); will not show the added record before update whole site, OR if the debugger was on, it worked fine.

Removing "method:'get'" or setting it to post, solved the problem

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!