EasyUI Forum
April 29, 2024, 01:59:34 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
  Home Help Search Login Register  
  Show Posts
Pages: [1] 2
1  General Category / General Discussion / Re: AJAX Window on: July 18, 2018, 12:47:07 AM
Awesome- Thanks!
2  General Category / General Discussion / AJAX Window on: July 16, 2018, 03:14:38 PM
Is there a way I can return an entire window using AJAX?

I currently have this AJAX call:

Code:

$.ajax({
url: 'ajax/update_project_item2.php',
type: 'post',
data: {'select':select,'items':jsonString},
  success: function(data, status) {
   $('#test').append(data);
  }

});

I have this PHP:

Code:
$type = $_POST['select']; // This is the select box option
$items = ($_POST['items']); // This is a Json string with the checkbox array in

 
 
 switch ($type)
 {
  case "mode":
 
  echo  '<div id="w" class="easyui-window" title="Basic Window" data-options="iconCls:\'icon-save\'" style="width:500px;height:200px;padding:10px;">
        The window content.
    </div>';
 
 
  break;
 
  case "position":
 
  break;
 
  case "colour":
 
  break;
 
  default:
 
  break;
 }
 

Ideally I could use each part of the case statement to return a different easyUI window. The reason for this is that I want to add a load of combo boxes that would be built dynamically based on the '$items' variable. This almost seems to work, but is missing something!

Thanks!
3  General Category / EasyUI for jQuery / Re: Multiple Delete from data grid on: July 03, 2018, 03:37:42 PM
I've solved this! I'm sure there is a more efficient way to do it though. My code is here in case it helps anyone else out

Code:
        function destroyProject(){
 
                var ids = [];
                var rows = $('#dg').datagrid('getChecked');
                for(var i=0; i<rows.length; i++){
                    ids.push(rows[i].row_id);
                }

                // We loop through each project and then delete it
                $.each(ids, function (index, value) {
                  $.post('destroy_project.php',{id:value},function(result){
                         
                          if (result.success){
                          } else {
                              $.messager.show({    // show error message
                                  title: 'Error',
                                  msg: result.errorMsg
                              });
                          }
                      },'json')
                }

                 
         
        );
                $('#dg').datagrid('reload');    // reload the user data

        }
4  General Category / EasyUI for jQuery / Multiple Delete from data grid on: July 03, 2018, 12:41:29 PM
Hey guys,

I have the option to delete records from a datagrid. It gets a bit tedious when it comes to deleting multiple records. I have set the datagrid up with check boxes to appear, and can multi select them. The next part is where I get stuck. Is there a way that I can put the values into an array and send via AJAX to a php file? Could you help me with that?

Thanks,

EDIT:

So far I have tried to reuse a function found in one of the tutorials:

Code:
function test() {
        var ids = [];
        var rows = $('#dg').datagrid('getChecked');
        for(var i=0; i<rows.length; i++){
            ids.push(rows[i].id);
        }
        alert(ids.join('\n'));
        }

This seems like it should work, but the alert box is empty. If I could fill it, I could then use the loop to do multiple AJAX calls, unless there is a more sensible way?
5  General Category / EasyUI for jQuery / Re: Combobox from PHP on: January 05, 2018, 12:22:04 PM
Hi all,

I found out that the issue was due to how the data was encoded. I managed to bodge around it by using this working code:

Code:

<?php
    
//open connection to mysql db
$conn = @mysqli_connect('XXX','XXX','XXXX');
mysqli_select_db($conn'XXXX');


    
//fetch table rows from mysql db
    
$sql "select fixture_id, custom_name from fixture_details";
    
$result mysqli_query($conn$sql) or die("Error in Selecting " mysqli_error($conn));

    
$rows = array();
    while(
$r mysqli_fetch_assoc($result)) {
    
$rows[] = $r;
    }
    
    
    function 
utf8ize($d) {
    
if (is_array($d)) {
    
foreach ($d as $k => $v) {
    
$d[$k] = utf8ize($v);
    
}
    
} else if (is_string ($d)) {
    
return utf8_encode($d);
    
}
    
return $d;
    }
    
    echo 
json_encode(utf8ize($rows))


?>



6  General Category / EasyUI for jQuery / Combobox from PHP on: January 03, 2018, 05:43:57 AM
Hi All,

I'm trying to load data from a database into a combo box. MY current Code is this:

Code:
 <input id="cc1" class="easyui-combobox" data-options="
        valueField: 'fixture_id',
        textField: 'custom_name',
        url: 'combobox_fixture.php',
        onSelect: function(rec){
            var url = 'combobox_mode.php?id='+rec.id;
            $('#cc2').combobox('reload', url);
        }">
        
<input id="cc2" class="easyui-combobox" data-options="valueField:'mode_id',textField:'custom_mode'">



My PHP file looks like this:

Code:

<?php
    
//open connection to mysql db
$conn = @mysqli_connect(XXXXXXXX');
mysqli_select_db($conn, '
XXXXXXX');


    //fetch table rows from mysql db
    $sql = "select fixture_id, custom_name from fixture_details";
    $result = mysqli_query($conn, $sql) or die("Error in Selecting " . mysqli_error($conn));

    //create an array
    $data = array();

    while ( $row = $result->fetch_assoc() ){
    
    
     $id = $row['
fixture_id'];
     $name = $row['
custom_name'];
   
$data[] = ['
fixture_id' => json_encode($id), 'custom_name' => json_encode($name)];
    }
    
echo json_encode($data);
   
    

This is a sample output of the JSON encode:
Code:
[{"fixture_id":"\"19\"","custom_name":"\"MAC Viper Profile\""},{"fixture_id":"\"20\"","custom_name":"\"MAC Viper Wash\""},{"fixture_id":"\"21\"","custom_name":"\"Molefay Two Light\""},{"fixture_id":"\"22\"","custom_name":"\"Mythos\""},{"fixture_id":"\"23\"","custom_name":"\"Robin 100 LEDBeam\""},{"fixture_id":"\"24\"","custom_name":"\"Robin Pointe\""},{"fixture_id":"\"25\"","custom_name":"\"Source 4 - 25\\\/50 Zoom \""},{"fixture_id":"\"26\"","custom_name":"\"Arena Zoomspot Narrow\""},{"fixture_id":"\"27\"","custom_name":"\"Arena Theatre Fresnel\""},{"fixture_id":"\"28\"","custom_name":false},{"fixture_id":"\"29\"","custom_name":"\"StudioCOB FC\""},{"fixture_id":"\"30\"","custom_name":"\"ARRI Junior 1000\""},{"fixture_id":"\"31\"","custom_name":"\"MAC Quantum \""},{"fixture_id":"\"32\"","custom_name":"\"CE Source 4 - 25\\\/50 Zoom \""},{"fixture_id":"\"33\"","custom_name":"\"Mac Aura XB\""},{"fixture_id":"\"34\"","custom_name":"\"Sunstrip\""},{"fixture_id":"\"35\"","custom_name":"\"Lanta Fireball Par64\""},{"fixture_id":"\"36\"","custom_name":"\"P-5\""},{"fixture_id":"\"37\"","custom_name":"\"4 Cell Mole\""},{"fixture_id":"\"38\"","custom_name":"\"Atomic 3000\""},{"fixture_id":"\"39\"","custom_name":"\"Spikie\""},{"fixture_id":"\"40\"","custom_name":"\"Source 4\""},{"fixture_id":"\"41\"","custom_name":"\"Sceptron \\\/ LED Bars\""},{"fixture_id":"\"42\"","custom_name":"\"XLED RGBW\""},{"fixture_id":"\"43\"","custom_name":"\"Intella Storm 1000\""},{"fixture_id":"\"44\"","custom_name":"\"Pageant CM-600Z\""},{"fixture_id":"\"45\"","custom_name":"\"XP-1000WZ\""},{"fixture_id":"\"46\"","custom_name":"\"XP-20R BSW\""},{"fixture_id":"\"47\"","custom_name":"\"GL-6\""},{"fixture_id":"\"48\"","custom_name":"\"Stormy CC\""},{"fixture_id":"\"49\"","custom_name":"\"Rama 1.2kW Fresnel\""},{"fixture_id":"\"50\"","custom_name":"\"Mirror Ball\""},{"fixture_id":"\"51\"","custom_name":"\"R1 Wash\""},{"fixture_id":"\"52\"","custom_name":"\"Source 4\""},{"fixture_id":"\"53\"","custom_name":"\"Fresnel 1.2kW \""}]

This works, mostly, but all of the values that go into the combobox have "" around them.
1) How can I get rid of these?

2) Is there a way that I can do this with a text box instead of a combobox?
7  General Category / EasyUI for jQuery / Easy UI for Offline Use on: August 22, 2017, 03:51:48 AM
Hi All,

Is it possible to change Easy UI so that it could work off line? Ideally I want to be able to put a folder onto any computer and then have something that is self contained. I can imagine that this would be fine as long as you store the data to a JSON file instead of putting it into a DB?

Could anyone give me some help and advice on what I would need to do?

Thanks,

AJLX
8  General Category / EasyUI for jQuery / Re: Date Time Box Add Year Button on: March 05, 2017, 10:49:58 AM
Thanks,

I've added that code into the body of the page, and it just adds a new date box. presumably I need to put it somewhere sensible!?

9  General Category / EasyUI for jQuery / Date Time Box Add Year Button on: March 02, 2017, 04:39:01 AM
Hello Guys,

I want to add a button to the date box editor so that when I click on it, it selects the same date, but next year. So if today is
02/03/2017 when I click this button it returns 02/03/2018. It should be simple, but I'm totally new to Jquery. I come for a PHP background. I can understand you not wanting to give me the full answer, but could you help me with some advice on the steps I need to take.

Thanks,

Andy
10  General Category / EasyUI for jQuery / Re: Why is my Save not working? on: November 13, 2016, 01:31:20 AM
Thanks for replying,
Just to make things clear, this isn't for a commercial product, it's just a little project in my spare time. If I use hard variables in my php code, instead of the $_REQUEST ones, then it works. So the SQL statement appears to be correct.

If I have a hidden field in my form, and give it a hard "value" it seems to work, but if I give any of the other fields a value, then they don't seem to make it through.

Interestingly, If I add an action to the form code, and then a submit button, the button doesn't seem to work either?

When I click the save button, it adds a blank row to the Db, so I think they're communicating, and there is something either in the form, or the js code that is stopping it.

Thanks guys
11  General Category / EasyUI for jQuery / Re: Why is my Save not working? on: November 12, 2016, 03:19:36 AM
Anyone? I have ruled out the php file, so I'm guessing it's something to do with the Java function. I've tried deleted and changing it lots, but still can't find a solution. As I said before- I guess it's something simple!

Thanks

AJLX
12  General Category / EasyUI for jQuery / Why is my Save not working? on: November 09, 2016, 02:48:34 PM
Hi guys, I have the following code but for some reason it's not saving. I think whatever is wrong is super simple! I some test fields through by adding a value="something" onto each of the inputs, and that seems to work.

The form:

Code:
 <form id="fm" method="post" novalidate>
        <div class="fitem">
            <label>Unit Number:</label>
           <input name="projectID" type="hidden" class="easyui-textbox" value="<?php echo $project_id;?>" >
           
            <input name="unit" class="easyui-textbox" >
           
           
        </div>
        <div class="fitem">
            <label>Address:</label>
            <input name="address" class="easyui-textbox" >
        </div>
        <div class="fitem">
            <label>Contents 1:</label>
            <input name="contents1" class="easyui-textbox">
        </div>
        <div class="fitem">
            <label>Contents 2:</label>
            <input name="contents2" class="easyui-textbox">
        </div>
        <div class="fitem">
            <label>Contents 3:</label>
            <input name="contents3" class="easyui-textbox">
        </div>
       
        <div class="fitem">
            <label>Contents 4:</label>
            <input name="contents4" class="easyui-textbox">
        </div>
        <div class="fitem">
            <label>Position Name:</label>
            <input name="position" class="easyui-textbox" >
        </div>
     
    </form>
This is the Java function:
 
Code:
function saveItem(){
$('#fm').form('submit',{
url: url,
onSubmit: function(){
return $(this).form('validate');
},
success: function(result){
var result = eval('('+result+')');
if (result.errorMsg){
$.messager.show({
title: 'Error',
msg: result.errorMsg
});
} else {
$('#item').dialog('close'); // close the dialog
$('#dg').datagrid('reload'); // reload the item data
}
}
});
}
This is the PHP file:

Code:
<?php

$project 
htmlspecialchars($_REQUEST['projectID']);
$unit htmlspecialchars($_REQUEST['unit']);
$address htmlspecialchars($_REQUEST['address']);
$contents1 htmlspecialchars($_REQUEST['contents1']);
$contents2 htmlspecialchars($_REQUEST['contents2']);
$contents3 htmlspecialchars($_REQUEST['contents3']);
$contents4 htmlspecialchars($_REQUEST['contents4']);
$position htmlspecialchars($_REQUEST['position']);

$conn = @mysql_connect('XXXXXXX','XXXXXX','XXXXXX');
mysql_select_db('XXXXX'$conn);


$sql "insert into pal_label(project_id,unit_no,address,contents1,contents2,contents3,contents4,stage_position) values('$project','$unit','$address','$contents1','$contents2','$contents3','$contents4','$position')";
$result = @mysql_query($sql);
if (
$result){
echo json_encode(array(
'row_id' => mysql_insert_id(),
'project_id' => $project,
'unit_no' => $unit,
'address' => $address,
'contents1' => $contents1,
'contents2' => $contents2,
'contents3' => $contents3,
'contents4' => $contents4,
'stage_position' => $position,

));
} else {
echo json_encode(array('errorMsg'=>'Some errors occured.'));
}
?>



13  General Category / EasyUI for jQuery / Re: Dynamically filling an editable combo box on: September 10, 2016, 03:38:48 AM
Hey,


Thanks for taking the time to reply, I managed to get side tracked with other projects.

 I now have this:
Code:
<th field="mode_id" width="10%" align="right" 	editor:{
type:'combobox',
options:{
url:'mode_id_select.php',
valueField:'fixture_id',
required:true

onBeforeLoad:function(param){
var index = $(this).closest('tr.datagrid-row').attr('datagrid-row-index');
var row = $('#dg').datagrid('getRows')[index];
param.fixture_id = row.fixture_id;
}
}
}, >Mode</th>

And it still isn't working? Any ideas please?
14  General Category / EasyUI for jQuery / Dynamically filling an editable combo box on: August 22, 2016, 09:49:44 AM
Hey guys,

I have the following code to create a combo box:
Code:
<th field="spot" width="10%" align="center" sortable="true" editor="text">Spot #</th>
<th field="fixture_id" width="20%" sortable="true">Fixture ID</th>
<th field="mode_id" width="10%" align="right" editor:{
type:'combobox',
options:{
url:'mode_id_select.php',
valueField:'fixture_id',
required:true
}
}
}, >Mode</th>
<th field="dmx_univ" width="10%" align="right" sortable="true" editor="text">Universe</th>


And the following PHP file:
Code:
<?php 
require ('../Inx/mysqli_project.php');
$items = array();
$fixture_id = isset($_POST['fixture_id'])
$sql "SELECT mode_id FROM fixture_details WHERE fixture_id = '$fixture_id'";
$result $con->query($sql);

if (
$result->num_rows 0)
{
// output data of each row
while($row $result->fetch_assoc())
array_push($items$row);

}

echo json_encode($items);
?>


Basically to run the SQL statement I need to use the fixture_id value from the same row. So somehow I need to send that across to the PHP file. Can someone help me with doing this please?

Thanks,

Andy
15  General Category / EasyUI for jQuery / Drag ad drop Issue on: April 15, 2016, 12:24:45 PM
Hello All,

I want to use the EasyUI drag and drop. I want to be able to drag and drop a div, and then send the contents of the DIV via a form field, or some other way to a PHP file where I can then process it. How would I go about this? I have tried playing about with the demos but to no success.

Thanks,

Andy
Pages: [1] 2
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!