EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: idirwantono on February 09, 2016, 08:16:23 AM



Title: last update data in datagrid edit dialog box (NOT SOLVED)
Post by: idirwantono on February 09, 2016, 08:16:23 AM
dear all,
i opened 2 datagrid with different tab browser..i edited data in first datagrid...then i want to view the data in second datagrid with the same id key..but data cannot be change with last updated...how to keep data can be view with the last update..thank you


Title: Re: last update data in datagrid edit dialog box
Post by: stworthy on February 09, 2016, 06:39:10 PM
How do you edit and update a row? Please show an example to demonstrate your issue.


Title: Re: last update data in datagrid edit dialog box
Post by: idirwantono on February 09, 2016, 07:35:15 PM
help me all


Title: Re: last update data in datagrid edit dialog box
Post by: idirwantono on February 09, 2016, 07:36:29 PM
How do you edit and update a row? Please show an example to demonstrate your issue.

ok friend wait....i will capture my problem


Title: Re: last update data in datagrid edit dialog box
Post by: idirwantono on February 09, 2016, 07:49:48 PM
How do you edit and update a row? Please show an example to demonstrate your issue.

1. First i open 2 datagrid with different tab browser
datagrid scipt :
$(function() {
  var datanya = <?php echo json_encode($_POST); ?>;
  var type = '<?=$TANDA; ?>';
    $("#result").datagrid({
        //url : $.post('<?= site_url() ?>/tiket/searchResult/',datanya,'success'),
      url : '<?= site_url() ?>/masterp/searchResult/type/'+type,
       
        method : 'POST',
        queryParams: datanya,
        columns:[[
            {field:'KD_Cust',title:'KD_Cust',sortable:true},
            {field:'Nama_Cust',title:'Nama_Cust',sortable:true},
            {field:'Alamat',title:'Alamat',sortable:true},
            {field:'Telp',title:'Telp',sortable:true},
          {field:'CP',title:'CP',sortable:true},
            {field:'Nama_CustType',title:'Cust Type',sortable:true},

         
         {field:'IsAktif',title:'IsAktif',sortable:true,formatter:formatPrice}
         
        ]],
        toolbar:"#toolbard",
        pagination:"true",
        nowrap: "false",
        pageSize: 10,
        fitcolumns: "true",
        rownumbers: "false",
   width: "auto",
      height: "300",
   singleSelect: "true"
     
    })
});
2. Then i edited the data from first datagrid, example  before name field is AAAA, after edit is AAAABBBB
script edit
 function EDITDatas(){
         var row = $('#result').datagrid('getSelected');
         if (row){
            $('#dlgad').dialog('open').dialog('setTitle','Edit Data Employee');
            row.menumm="<?=$menunameid;?>";
            $('#fmad').form('load',row);
            url = '<?=site_url() ?>/masterp/editocustomerr/ID/'+row.Cust_ID;
         }
      }

script edit form
 <div id="dlgad" class="easyui-dialog" style="width:380px;height:auto;padding:10px 20px"
         closed="true" buttons="#dlgad-buttons" data-options="modal:true,iconCls:'icon-save',resizable:true,closable:false  ">
      <div class="ftitle">Data Customer</div>
      <form id="fmad" method="post" action="<?=site_url() ?>/masterp/editocustomerr/"  novalidate>

          <div class="fitem">
                <label>Kode_Cust</label>
                <input name="KD_Cust" id="KD_Cust"  style="width:200px;"  class="easyui-validatebox" required="true">

      
            </div>
         <div class="fitem">
                <label>Nama</label>
                <input name="Nama_Cust" id="Nama_Cust"  style="width:200px;" class="easyui-validatebox" required="true">
            <input name="menumm" id="menumm" type="hidden" value="<?=$menunameid;?>"/>
            
            
            </div>
      
         <div class="fitem">
                <label>Alamat</label>
                <input name="Alamat" id="Alamat"  style="width:200px;">
            </div>
         <div class="fitem">
                <label>phone</label>
                <input name="Telp" id="Telp"  style="width:200px;">
            </div>
         <div class="fitem">
                <label>CP</label>
                <input name="CP" id="CP"  style="width:200px;" >
            </div>
         
   <label id="resultzen"> 
         <div class="fitem">
                <label>Customer Type</label>
       
            <select name="m_CustType_ID" id="m_CustType_ID"  class="easyui-combobox" required="true"   >
                                                <?
foreach ($custipe as $resulejs) {
?>
         <option value="<?= $resulejs['CustType_ID']; ?>"><?= $resulejs['KD_CustType']; ?> -- <?= $resulejs['Nama_CustType']; ?></option>
         <?php
}
?>
       </select>    
         
            </div>
         </label>
         <div class="fitem">
                <label>IsAktif</label>
                <input type="checkbox" value="1" name="IsAktif" id="IsAktif" >
            </div>
      
      
      </form>
   </div>
   <div id="dlgad-buttons">
   <a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveEmp()">Save</a>
      <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="
      $.messager.confirm('Confirm', 'Closed Without Saved?', function(r){
   if (r){
      javascript:$('#dlgad').dialog('close')
   }
});
      ">Close</a>
      <a href="#" class="easyui-linkbutton" iconCls="icon-undo" onclick="refreshdif()">Reload</a>
   </div>

3. I saved the data, then i want see the data from second datagrid with the same id key..but in the second datagrid the data not update, the value data in name field still AAAA, not AAAABBBB

Thank you


Title: Re: last update data in datagrid edit dialog box (NOT SOLVED)
Post by: finzaiko on February 09, 2016, 09:40:59 PM
Hello agan idirwantono, i try to nimbrung

have you check after your submit your data has already changed in your database, if yes just call reload after save $('#yourDatagridId').datagrid('reload'); if no make sure your data save changed you can check on your firebug post header


Title: Re: last update data in datagrid edit dialog box (NOT SOLVED)
Post by: aswzen on February 09, 2016, 10:11:22 PM
i try to nimbrung too

try to console.log($("#result").datagrid('getRows')); in javascript console after updating data

and then see your javascript console in browser..and then find the row..check if it already updated or not..if not updated that mean your update code is failing/error


Title: Re: last update data in datagrid edit dialog box (NOT SOLVED)
Post by: idirwantono on February 11, 2016, 08:47:04 PM
i try to nimbrung too

try to console.log($("#result").datagrid('getRows')); in javascript console after updating data

and then see your javascript console in browser..and then find the row..check if it already updated or not..if not updated that mean your update code is failing/error

my fren aswzen,,
after updating the data in first datagrid, the results of the update can be seen in the first datarid...but if i see the second datagrid in different tab browser, data cannot be change with last updated..but if i reload the second datagrid...the data has been change with last updated...nah...
I'd like is I do not need to click the reload button to see the data changes. when I click the edit button then the edit form will appear that displays the most updated data, the data in the second DataGrid does not update not a problem.


Thank you with your answer and help me...ha ha ha


Title: Re: last update data in datagrid edit dialog box (NOT SOLVED)
Post by: aswzen on February 14, 2016, 07:50:12 PM
you just put reload function after your updated succesfully commited
function saveEmp(){
  //your save code
  $('#yourDatagridId').datagrid('reload');
}


Title: Re: last update data in datagrid edit dialog box (NOT SOLVED)
Post by: idirwantono on February 14, 2016, 10:13:23 PM
you just put reload function after your updated succesfully commited
function saveEmp(){
  //your save code
  $('#yourDatagridId').datagrid('reload');
}


My Fren aswzen,

i have to tried to reload this datagrid after edit the data..n success in first datagrid..but datagrid in tab with different browser or datarid in different browser cannot be change...
or maybe my explanation is somewhat less so in this case..he2


so actually i opened two datagrid in the same time, but i opened with different browser..ok
Second step, i edited the data in first datagrid..edit success..and datagrid reload..( note : second datagrid cannot reload because second datagrid in different browser,,you can try if you opened google.com in two browser then you reload page in the first browser..certainly the browser that both are not automatically reload,,nah
well that's what I mean)

Okey. no problem..
but I would like when it opens in the second DataGrid with the same id key but with different browser..in the second datagrid data not update but when I click the edit button, a dialog box that contains the most updated data

   function saveEmp(){
         $('#fmad').form('submit',{
            url: url,
            onSubmit: function(){
               return $(this).form('validate');
            },
            success: function(result){
               var result = eval('('+result+')');
               if (result.success){
                  $.messager.show({   // show error message
                           title: 'Success',
                              //msg: result.errorMsg
                           msg: result.success
                        });
                  $('#dlgad').dialog('close');      // close the dialog
                  $('#result').datagrid('reload');   // reload the user data
               } else {
                  $.messager.show({
                     title: 'Error',
                     msg: result.msg
                  });
               }
            }
         });
      }


Title: Re: last update data in datagrid edit dialog box (NOT SOLVED)
Post by: finzaiko on February 14, 2016, 11:14:22 PM
try this
http://www.jeasyui.com/forum/index.php?topic=491.0


Title: Re: last update data in datagrid edit dialog box (NOT SOLVED)
Post by: aswzen on February 14, 2016, 11:29:28 PM
obviously we cannot achieve that using easyUI..
please try auto refresh datagrid like mas finzaiko said above

or use the browser session
http://stackoverflow.com/questions/20219977/how-to-pass-a-value-from-a-parent-window-to-another-html-page-using-javascript