Show Posts
|
Pages: [1] 2
|
2
|
General Category / General Discussion / Format a text box dd/mm/yyyy
|
on: June 12, 2017, 02:07:09 PM
|
I have a function that formats a cell from a MySQL db in a datagrid dd/mm/yyyy function formatDate1(val,row){ return formattedDate(val); }
function formattedDate(date) { var d = new Date(date || Date.now()), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear();
if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day;
return [day, month, year].join('/'); }
The edit form displays the date in a text box, as per the crud example. I thought I could use the same function as follows: <input name="date" class="easyui-textbox" data-options="formatter:formatDate1">
but it has no effect. Ideally I would like to use a datebox. What do I need to change to display a date dd/mm/yyyy so that when the form is saved the date is yyyy/mm/dd . Thanks.
|
|
|
6
|
General Category / EasyUI for jQuery / Re: Passing Sales Force Data into a Data Grid
|
on: September 08, 2016, 03:25:26 PM
|
Here is the code that achieves what I wanted - taking output from a Sales Force query and formatting it as required by a EasyUI datagrid. //--Get the Sales Force Data $response = $mySforceConnection->query($query);
//--Encode and decode - for some reason $data = json_encode((array)$response); $x = json_decode($data,true);
//--Empty Array $q = array();
//--Add array element for number records $q['total'] = $numRecs; //--Copy the array element from original query with data $q['rows'] = $x['records'];
//--JSON Encode the new array $y = json_encode($q);
//--Return the array to Ajax call echo ($y);
And here's a snippet of the validated JSON.. { "total":193, "rows":[ { "Id":null, "CreatedDate":"2016-08-28T14:43:45.000Z", "Leader__c":"GF", "Location__c":"Postbridge", "Service_Date__c":"2016-09-03", "Service_Time__c":"14:30", "Service_Type__c":"Baptism" }, { "Id":null, "CreatedDate":"2016-08-17T20:43:10.000Z", "Leader__c":"GF", "Location__c":"Ashburton", "Service_Date__c":"2016-09-04", "Service_Time__c":"08:00", "Service_Type__c":"HC 2" }, { "Id":null, "CreatedDate":"2016-08-17T20:43:10.000Z", "Leader__c":"GF", "Location__c":"Bickington", "Service_Date__c":"2016-09-04", "Service_Time__c":"09:00", "Service_Type__c":"HC 2" }, { "Id":null, "CreatedDate":"2016-08-17T20:43:10.000Z", "Leader__c":"MC", "Location__c":"Holne", "Service_Date__c":"2016-09-04", "Service_Time__c":"10:30", "Service_Type__c":"HC 1" },
</code> I struggled a bit with the array manipulation but it works. Any code improvement suggestions most welcome !
|
|
|
7
|
General Category / EasyUI for jQuery / Re: Passing Sales Force Data into a Data Grid
|
on: August 24, 2016, 03:46:28 AM
|
Thanks for this url. I have added this JavaScript at the head of the page displaying the list: <script type="text/javascript"> var url; $('#dg').datagrid({ loadFilter: function(data){ total: data.total, , rows: data.records } })
However I get two errors: Syntax Error: total: data.total "Expecting expression, got ',' Type Error: Rows is undefined Here is a sample of the response data: { "queryLocator":null, "done":true, "records":[ { "Id":null, "CreatedDate":"2016-08-17T20:43:10.000Z", "Leader__c":"GF", "Lectionary6__r":{ "Id":null, "Colour__c":"Green", "Lectionary_Date__c":"2016-09-04", "Period_Name__c":"Trinity 15", "Selected_Reading_Line__c":"Deuteronomy 30.15\u2013end, Psalm 1, Philemon 1\u201321, Luke 14.25\u201333" }, "Location__c":"Ashburton", "Service_Date__c":"2016-09-04", "Service_Time__c":"08:00", "Service_Type__c":"HC 2" }, { "Id":null, "CreatedDate":"2016-08-17T20:43:10.000Z", "Leader__c":"GF", "Lectionary6__r":{ "Id":null, "Colour__c":"Green", "Lectionary_Date__c":"2016-09-04", "Period_Name__c":"Trinity 15", "Selected_Reading_Line__c":"Deuteronomy 30.15\u2013end, Psalm 1, Philemon 1\u201321, Luke 14.25\u201333" }, "Location__c":"Bickington",
Your solution seems close as the data format is exactly as per the post you referred to. Is the problem the absence of a Total element in the JSON ? Any further thoughts please ? Thanks.
|
|
|
8
|
General Category / EasyUI for jQuery / Passing Sales Force Data into a Data Grid
|
on: August 23, 2016, 02:59:18 PM
|
I am trying to load Sales Force data into a Data Grid using the CRUD example. I have generated JSON from a Sales Force Query. Here is an extract: { "queryLocator":null, "done":true, "records":[ { "Id":null, "CreatedDate":"2016-08-17T20:43:10.000Z", "Leader__c":"GF", "Lectionary6__r":{ "Id":null, "Colour__c":"Green", "Lectionary_Date__c":"2016-09-04", "Period_Name__c":"Trinity 15", "Selected_Reading_Line__c":"Deuteronomy 30.15\u2013end, Psalm 1, Philemon 1\u201321, Luke 14.25\u201333" }, "Location__c":"Ashburton", "Service_Date__c":"2016-09-04", "Service_Time__c":"08:00", "Service_Type__c":"HC 2" }, { "Id":null, "CreatedDate":"2016-08-17T20:43:10.000Z", "Leader__c":"GF", "Lectionary6__r":{ Here is the JSON which comes from the CRUD example { "total":"105", "rows":[ { "id":"3", "firstname":"fname1234BBBB", "lastname":"lname10....", "phone":"Lacock 4919999", "email":" name991@gmail.com" }, { "id":"7", "firstname":"fname413ffffggxx", "lastname":"lname999x", "phone":"0123456", "email":" name4@gmail.com" }, Here are the important lines from get_users.php which create the JSON array. define("USERNAME", "--------------------"); define("PASSWORD", "--------"); define("SECURITY_TOKEN", "-----------");
require_once ('soapclient/SforceEnterpriseClient.php'); $mySforceConnection = new SforceEnterpriseClient(); $mySforceConnection->createConnection("soapclient/generateEnterprise.wsdl"); $mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
$query = "SELECT Service_Date__c, Service_Time__c, CreatedDate, Notes__c, Leader__c, Location__c, Service_Type__c, Lectionary6__r.Lectionary_Date__c,Lectionary6__r.Colour__c,Lectionary6__r.Period_Name__c, Lectionary6__r.Selected_Reading_Line__c from Service3__c WHERE Web_Publish__c = True ORDER BY Service3__c.Service_Date__c, Service3__c.Service_Time__c ";
$response = $mySforceConnection->query($query);
$data = json_encode((array)$response);
echo $data; The SF JSON validates - the only difference I can see relates to the header - the EasyUI includes the number of rows. Is this important ? Can anyone suggest what I need to change to get the SF data to load into the grid ? Any help or suggestions much appreciated. Thanks.
|
|
|
11
|
General Category / EasyUI for jQuery / Changing the View of a Datagrid
|
on: June 25, 2016, 03:46:57 AM
|
Is there any way to change from a detailview to a groupview in a Datagrid using a button - as you can do to change the records displayed. For example the code code below does not give an error and changes the server data source, but it does not show any grouping. function group () { alert("Grouped"); $('#dg').datagrid({ url:'get_users_filtered.php', view: groupview, groupField: firstname, groupFormatter:function(value,rows){ return value + ' - ' + rows.length + ' Items'; } }); }
What am I doing wrong ? Thanks.
|
|
|
12
|
General Category / EasyUI for jQuery / Re: Main form - sub-form ( One-to-many data relationship )
|
on: June 25, 2016, 03:39:53 AM
|
Thanks Aswzen. I am sure you are right - but then what you say might well apply to all the functionality in EasyUI. EasyUI implements powerful features with less code than using jQuery and JS. The attached screenshot perhaps shows one way to handle 1 to many data relationships in EUI. But can anyone suggest a better approach ?
|
|
|
13
|
General Category / EasyUI for jQuery / Main form - sub-form ( One-to-many data relationship )
|
on: June 23, 2016, 12:37:18 PM
|
I hope to use EasyUI to replicate, with improvements, the functionality of a system created in Zoho Creator (screen shot attached) . The system provides a simple order creation form where it is possible to add multiple items (order lines) on the same form that displays the order header and order totals.
How should I go about doing this in EasyUI ? Thanks.
|
|
|
14
|
General Category / EasyUI for jQuery / Re: Updating Form fields after submission
|
on: April 28, 2016, 04:38:38 AM
|
The solution to updating a form field after submission, for example setting the name field to "", is: $('input[name="name"]').val("");[ To retrieve a field value use var email = $(“myfield“).val(); where myfield is an id. ] Here is a trivial example of using a php function ( in this case just returning server time ) to place a value directly into a form field - not actually an EasyUI form in this case but the principal is the same for all jQuery forms. <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $.post("post_receiver2.php", { }, function(data,status){ alert("Data: " + data + "\nStatus: " + status); $('input[name="fname"]').val(data); }); }); }); </script> </head> <body>
<form id='userForm'> <div><input type='text' name='fname' placeholder='Firstname' /></div> </form>
<button>Submit !</button>
</body> </html>
Here is the code in post_receiver2.php This means that, in a volume input situation, it is possible to retain selected field values and update read only fields with values drawing on php power.
|
|
|
15
|
General Category / EasyUI for jQuery / Updating Form fields after submission
|
on: April 24, 2016, 03:12:17 PM
|
I am exploring how EUI forms could be used for volume data input. I want to be able make changes to the fields after a submission in readiness for the next entry. For example, to retain some fields, to blank others and to allow some manipulation such as running an incrementing counter. I thought it might be possible to do something in the success: routine. But this doesn't work. $(function(){ $('#ff').form({ url:'form3_proc.php', onSubmit:function(){ return $(this).form('validate'); }, success:function(data){ $.messager.alert('Info', data, 'info'); alert ("ddd"); var txt = $('#name'); txt.val("updated " + txt.val()); } }); });
Any help to point me at some sample code to do something along these lines would be much appreciated. Thanks.
|
|
|
|