EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: alkaf on October 16, 2012, 10:19:42 PM



Title: HelpMe...getSelection in datagrid
Post by: alkaf on October 16, 2012, 10:19:42 PM
her how to send an array of variables to be stored in the database getselection
I have a script like this
function save_pegawai(){
      $('#fm').form('submit',{
        url: url,
        onSubmit: function(){
         var nips = [];
         var rows = $('#pegawai').datagrid('getSelections');
         for(var i=0; i<rows.length;i++){
            nips.push(rows.nip);
         }

         alert((nips.join('\n'));
          //return $(this).form('validate');
        },
         
        success : function(result){
          var result = eval('('+result+')');
          if(result.success){
         
         //alert(nips.join('\n'));
           // $('#dlg').dialog('close');//close dialog
            //$('#dg').datagrid('reload'); //reload user data
          }else{
            $.messager.show({
              title: 'Error',
              msg: result.msg
            });
          }
        }
      });
    }
how to store nips into the database.
help me?  :-[


Title: Re: HelpMe...getSelection in datagrid
Post by: stworthy on October 19, 2012, 12:52:16 AM
The simplest way is to post the nips array to server. The code looks like this:
Code:
var nips = [];
var rows = $('#pegawai').datagrid('getSelections');
for(var i=0; i<rows.length; i++){
nips.push(rows[i].nip;
}
$.post(yoururl, {nips: nips.join(',')}, function(result){
});