Page Index Toggle Pages: 1 [2] 3  Send TopicPrint
Very Hot Topic (More than 25 Replies) New questions, about localization and value sorting (Read 36280 times)
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: New questions, about localization and value sorting
Reply #15 - Mar 21st, 2014 at 2:54pm
Print Post  
========================
I solved that, it works now. Thank you!
========================

One more question, I asked how to bind a existing list into "New Appointment" dropdownlist here : http://mindfusion.eu/Forum/YaBB.pl?num=1392669565.
Reply #10

Right now I already have a List<string> which contains my wanted values. But once I implemented your code, the dropdownlist is ok but no values once I click it, blank dropdownlist...how to associate the list with the dropdownlist?

Thank you!



Lyubo wrote on Mar 21st, 2014 at 12:58pm:
Hi,

Check out this sample application: https://mindfusion.eu/_samples/WebPlanner.Database.zip.

It demonstrates one way to synchronize the planner's schedule with an underlying database.
The application uses SQL Compact Edition 4.0 as datastore, but the principle will remain the same with Oracle, too.

The database is updated as a response to an ItemCreated, ItemModified, ItemInplaceEdited or ItemDeleted event. The appointments and contacts are matched in the database by the auto-id, which is cached in the Appointment.Tag property.

Regards,
Lyubo
« Last Edit: Mar 21st, 2014 at 7:31pm by Xylon »  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: New questions, about localization and value sorting
Reply #16 - Mar 21st, 2014 at 3:42pm
Print Post  
========================
I solved that, it works now. Thank you!
========================
Xylon wrote on Mar 21st, 2014 at 2:54pm:
One more question, I asked how to bind a existing list into "New Appointment" dropdownlist here : http://mindfusion.eu/Forum/YaBB.pl?num=1392669565.
Reply #10

Right now I already have a List<string> which contains my wanted values. But once I implemented your code, the dropdownlist is ok but no values once I click it, blank dropdownlist...how to associate the list with the dropdownlist?

Thank you!


PS: I followed your method, assigned the value from the list into the "result", I checked line by line, but still, there is no value in the dropdownlist of "New Appointment"


Lyubo wrote on Mar 21st, 2014 at 12:58pm:
Hi,

Check out this sample application: https://mindfusion.eu/_samples/WebPlanner.Database.zip.

It demonstrates one way to synchronize the planner's schedule with an underlying database.
The application uses SQL Compact Edition 4.0 as datastore, but the principle will remain the same with Oracle, too.

The database is updated as a response to an ItemCreated, ItemModified, ItemInplaceEdited or ItemDeleted event. The appointments and contacts are matched in the database by the auto-id, which is cached in the Appointment.Tag property.

Regards,
Lyubo

« Last Edit: Mar 21st, 2014 at 7:31pm by Xylon »  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: New questions, about localization and value sorting
Reply #17 - Mar 26th, 2014 at 1:29pm
Print Post  
About bind the calendar data with a datatable, as we discussed before, I have many contacts, and in every contacts I have more than one appointment.

But in my datatable, I need one contact with its first appointment in one row, then the next row will be same contact with its second appointment, and so on...

This is a big problem what i have right now...

Thank you very much!   

Lyubo wrote on Mar 21st, 2014 at 12:58pm:
Hi,

Check out this sample application: https://mindfusion.eu/_samples/WebPlanner.Database.zip.

It demonstrates one way to synchronize the planner's schedule with an underlying database.
The application uses SQL Compact Edition 4.0 as datastore, but the principle will remain the same with Oracle, too.

The database is updated as a response to an ItemCreated, ItemModified, ItemInplaceEdited or ItemDeleted event. The appointments and contacts are matched in the database by the auto-id, which is cached in the Appointment.Tag property.

Regards,
Lyubo

  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: New questions, about localization and value sorting
Reply #18 - Mar 26th, 2014 at 4:13pm
Print Post  
Hi Lyubo, one more question in Javascript.

Say I create new appointment, right now in the "New Appointment" window I have subject as a textbox, location as a dropdownlist, then start time and end time of course. Values in the dropdownlist are from database, here I achieved that.

My code is here 
Code (Javascript)
Select All
var a = JSON.parse('<% = this.javaSerial.Serialize(this.eventValue) %>');

		    var populateEventTypeItems = function ()
		    {
		        var result = [];
		        for (var i = 0; i < a.length; i++) {
		            result.push({value: a[i], text: a[i]});
		        }
		        return result;
		    }

var eventType = this.createDropDownList({
		            id: 'EventsType',
		            items: populateEventTypeItems(),
		            initValue: this.item.subject,
		            addEmptyValue: false
		        });
		        eventType.element.style.width = "355px"

var locationOriginal = this.getControls()['location'];
		        locationOriginal.element.parentNode.appendChild(eventType.element);
		        //locationOriginal.element.remove();
		        locationOriginal.element.parentNode.removeChild(locationOriginal.element);

		        // Replace also the control in the forms controls collection
		        this.getControls()['location'] = eventType;

 



It seems work, but to obtain the textbox value of subject, I got error saying sth like "id is null blablabla"

My code of subject textbox is below
Code (Javascript)
Select All
var subjectText = document.getElementById('subject');
		        document.getElementById('subject').appendChild(subjectText);

var subjectOriginal = this.getControls()['subject'];
		        subjectOriginal.element.parentNode.appendChild(subjectText.element);
		        subjectOriginal.element.parentNode.removeChild(subjectOriginal.element);
		        this.getControls()['subject'] = subjectText;


 



How to correct my code to display new created appointment properly?

Lyubo wrote on Mar 21st, 2014 at 12:58pm:
Hi,

Check out this sample application: https://mindfusion.eu/_samples/WebPlanner.Database.zip.

It demonstrates one way to synchronize the planner's schedule with an underlying database.
The application uses SQL Compact Edition 4.0 as datastore, but the principle will remain the same with Oracle, too.

The database is updated as a response to an ItemCreated, ItemModified, ItemInplaceEdited or ItemDeleted event. The appointments and contacts are matched in the database by the auto-id, which is cached in the Appointment.Tag property.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: New questions, about localization and value sorting
Reply #19 - Mar 27th, 2014 at 10:49am
Print Post  
Hi,

For the first snippet I replied to you here, explaining why there is an exception and how to fix it.

For the second part, I don't quite understand what you're trying to achieve there. The subject value is saved in the Appointment.Subject property (or Item.subject on the client), you can access it there.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: New questions, about localization and value sorting
Reply #20 - Mar 27th, 2014 at 3:22pm
Print Post  
In your example, the  "CreateAppointment" method seems will loop entire app.contacts every time if user create new appointment, is that right?
Code (Javascript)
Select All
foreach (Contact con in app.Contacts)
				{
					using (SqlCeCommand cmd = new SqlCeCommand
						(
							"INSERT INTO ContactEvents ([EventID], [ContactID]) " +
							"VALUES (@EVTID, @CNTID); ", conn
						))
					{
						cmd.Parameters.AddWithValue("EVTID", app.Tag);
						cmd.Parameters.AddWithValue("CNTID", con.Tag);

						cmd.ExecuteNonQuery();
					}
				} 



What if I only would like synchronize new appointment? Say only add new appointment value record into database/datatable?

Lyubo wrote on Mar 21st, 2014 at 12:58pm:
Hi,

Check out this sample application: https://mindfusion.eu/_samples/WebPlanner.Database.zip.

It demonstrates one way to synchronize the planner's schedule with an underlying database.
The application uses SQL Compact Edition 4.0 as datastore, but the principle will remain the same with Oracle, too.

The database is updated as a response to an ItemCreated, ItemModified, ItemInplaceEdited or ItemDeleted event. The appointments and contacts are matched in the database by the auto-id, which is cached in the Appointment.Tag property.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: New questions, about localization and value sorting
Reply #21 - Mar 27th, 2014 at 9:03pm
Print Post  
One more question, in the sample code, say I create a new appointment, the new appointment has headertext as name, location value, start time and end time, then the "ItemCreated" will be invoked after create action. In database the new appointment will have auto-id as a key, but on the calendar, is there a app.tag that matching auto-id in database?  If not how I delete the new created appointment since no id could match....

Lyubo wrote on Mar 21st, 2014 at 12:58pm:
Hi,

Check out this sample application: https://mindfusion.eu/_samples/WebPlanner.Database.zip.

It demonstrates one way to synchronize the planner's schedule with an underlying database.
The application uses SQL Compact Edition 4.0 as datastore, but the principle will remain the same with Oracle, too.

The database is updated as a response to an ItemCreated, ItemModified, ItemInplaceEdited or ItemDeleted event. The appointments and contacts are matched in the database by the auto-id, which is cached in the Appointment.Tag property.

Regards,
Lyubo

  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: New questions, about localization and value sorting
Reply #22 - Mar 28th, 2014 at 9:40am
Print Post  
Xylon wrote on Mar 27th, 2014 at 3:22pm:
In your example, the "CreateAppointment" method seems will loop entire app.contacts every time if user create new appointment, is that right?

That's right. It's done so because of how the database in the sample is designed. How exactly you will handle database updates in your application may be different. It will depend on your database design and specifications.

Xylon wrote on Mar 27th, 2014 at 9:03pm:
One more question, in the sample code, say I create a new appointment, the new appointment has headertext as name, location value, start time and end time, then the "ItemCreated" will be invoked after create action. In database the new appointment will have auto-id as a key, but on the calendar, is there a app.tag that matching auto-id in database? If not how I delete the new created appointment since no id could match....

In the sample, after a new appointment is inserted into the database, the generated auto-id of the new DB record is assigned to the Appointment.Tag property. It is then used for matching the DB record with the respective Appointment object. In the sample this is handled by these lines in the CreateAppointment method:

Code
Select All
cmd.CommandText = "SELECT @@IDENTITY as NewId";
// assign the id from the newly inserted database record
app.Tag = (int)(decimal)cmd.ExecuteScalar();

// Below is a snippet from the DeleteAppointment method

// using the id later for matching the appointment with its db record
using (SqlCeCommand cmd =
    new SqlCeCommand("DELETE FROM ContactEvents " +
                     "WHERE [EventID] = @EVTID ", conn))
{
    cmd.Parameters.AddWithValue("EVTID", app.Tag);
    // ... 


Regards,
Lyubo
  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: New questions, about localization and value sorting
Reply #23 - Mar 28th, 2014 at 6:43pm
Print Post  
But my application is reading the data into a datatable first then display on the calendar. For create, delete and edit action, all the actions will operate the datatable then call a stored procedure to insert the datatable into database.

Your code "app.Tag = (int)(decimal)cmd.ExecuteScalar();" works if the calendar connect with database directly, what if the calendar connects with datatable first? How to associate the auto generated id with new created appointment?

Lyubo wrote on Mar 28th, 2014 at 9:40am:
Xylon wrote on Mar 27th, 2014 at 3:22pm:
In your example, the "CreateAppointment" method seems will loop entire app.contacts every time if user create new appointment, is that right?

That's right. It's done so because of how the database in the sample is designed. How exactly you will handle database updates in your application may be different. It will depend on your database design and specifications.

Xylon wrote on Mar 27th, 2014 at 9:03pm:
One more question, in the sample code, say I create a new appointment, the new appointment has headertext as name, location value, start time and end time, then the "ItemCreated" will be invoked after create action. In database the new appointment will have auto-id as a key, but on the calendar, is there a app.tag that matching auto-id in database? If not how I delete the new created appointment since no id could match....

In the sample, after a new appointment is inserted into the database, the generated auto-id of the new DB record is assigned to the Appointment.Tag property. It is then used for matching the DB record with the respective Appointment object. In the sample this is handled by these lines in the CreateAppointment method:

Code
Select All
cmd.CommandText = "SELECT @@IDENTITY as NewId";
// assign the id from the newly inserted database record
app.Tag = (int)(decimal)cmd.ExecuteScalar();

// Below is a snippet from the DeleteAppointment method

// using the id later for matching the appointment with its db record
using (SqlCeCommand cmd =
    new SqlCeCommand("DELETE FROM ContactEvents " +
                     "WHERE [EventID] = @EVTID ", conn))
{
    cmd.Parameters.AddWithValue("EVTID", app.Tag);
    // ... 


Regards,
Lyubo

  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: New questions, about localization and value sorting
Reply #24 - Mar 31st, 2014 at 1:19pm
Print Post  
Hi,

Have a look at the tutorial here: http://msdn.microsoft.com/en-us/library/ks9f57t0(v=vs.100).aspx

You can assign temporary unique ids (i.e. generate new GUIDs) to newly created items' Tag property and store them also in your DataTable.
When inserting the new records with your stored procedure, you can query the database for the newly created auto-id (how this can be done is explained in the link above), match the appointment by the record's GUID value and update its Tag to the corresponding auto-id.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: New questions, about localization and value sorting
Reply #25 - Apr 3rd, 2014 at 3:55pm
Print Post  
But how to bind the corresponding contact id once I create a new appointment?

Say I click on the calendar to create new appointment, on the "New Appointment" window I could input the Name, type code, starttime and end time, once new appointment is created, "OnItemCreated" will be involked to insert the data into a new row in the datatable

the code here
Code
Select All
newRow["NAME"] = app.HeaderText;
            newRow["Type"] = app.Location.Id;
            newRow["START"] = app.StartTime;
            newRow["END"] = app.EndTime;

dt.Rows.Add(newRow) 


but...but, there is one column named "contact" in the datatable, it stores the contacts name. I checked the datatable via breakpoint, the new row, it has name, type, start time and end time but contact element is null coz the function didn't pass contact data into it.

The appointment. item is from ItemEventArgs e, so how to get the corresponding contact?

Reference:  the sample code you provided here: https://mindfusion.eu/_samples/WebPlanner.Database.zip.

Thank you!

Lyubo wrote on Mar 31st, 2014 at 1:19pm:
Hi,

Have a look at the tutorial here: http://msdn.microsoft.com/en-us/library/ks9f57t0(v=vs.100).aspx

You can assign temporary unique ids (i.e. generate new GUIDs) to newly created items' Tag property and store them also in your DataTable.
When inserting the new records with your stored procedure, you can query the database for the newly created auto-id (how this can be done is explained in the link above), match the appointment by the record's GUID value and update its Tag to the corresponding auto-id.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: New questions, about localization and value sorting
Reply #26 - Apr 4th, 2014 at 6:31am
Print Post  
Hi,

In the resource view, contacts are automatically associated with the appointments when creating new items. By default one can add or remove contact associations interactively through the New/Edit popup Form through the Contacts checkboxes or by moving an item with the mouse from one resource row to another. Contacts assigned to appointments can be accessed via the Appointment.Contacts collection.

The Database sample we provided there are three tables - 'Events' - to store appointments (there is no contact field there), 'Contacts' - to store contacts and 'ContactEvents' - to store associations between appointments and the contacts assigned to them. When inserting a new appointment into the database, first it's property values are stored in the Events table and an ID is assigned. Then, the item-contact relationship is established in the database with this query:

Code
Select All
using (SqlCeCommand cmd = new SqlCeCommand(
    "INSERT INTO ContactEvents ([EventID], [ContactID]) " +
    "VALUES (@EVTID, @CNTID); ", conn))
{
    cmd.Parameters.AddWithValue("EVTID", app.Tag);
    cmd.Parameters.AddWithValue("CNTID", con.Tag);

    cmd.ExecuteNonQuery();
} 



In your case, when you insert a new appointment, you can enumerate the Appointment.Contacts collection to get the contact name and add it too. Be aware though, that an appointment by default can be associated with more than one contact instance, so your code and/or database structure may need to adapt to that.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: New questions, about localization and value sorting
Reply #27 - Apr 15th, 2014 at 7:19pm
Print Post  
Hi,

I got an problem that confused me two days...

If I create a new appointment on the calendar, I input four values, app.headertext, app.Location, app.StartTime, and app.EndTime. Then my page is synchronized with a datatable that I am sure a new row is created with these values.

But...but...after I click save button, calendar is refreshed, nothing happen...I mean, the new appointment is not showing up on the calendar. There are only old appointments...

I know this is a very general description that hard to tell what the error is. But I really couldn't figure out more information about it...

Any hint?

Thank you!

Lyubo wrote on Apr 4th, 2014 at 6:31am:
Hi,

In the resource view, contacts are automatically associated with the appointments when creating new items. By default one can add or remove contact associations interactively through the New/Edit popup Form through the Contacts checkboxes or by moving an item with the mouse from one resource row to another. Contacts assigned to appointments can be accessed via the Appointment.Contacts collection.

The Database sample we provided there are three tables - 'Events' - to store appointments (there is no contact field there), 'Contacts' - to store contacts and 'ContactEvents' - to store associations between appointments and the contacts assigned to them. When inserting a new appointment into the database, first it's property values are stored in the Events table and an ID is assigned. Then, the item-contact relationship is established in the database with this query:

Code
Select All
using (SqlCeCommand cmd = new SqlCeCommand(
    "INSERT INTO ContactEvents ([EventID], [ContactID]) " +
    "VALUES (@EVTID, @CNTID); ", conn))
{
    cmd.Parameters.AddWithValue("EVTID", app.Tag);
    cmd.Parameters.AddWithValue("CNTID", con.Tag);

    cmd.ExecuteNonQuery();
} 



In your case, when you insert a new appointment, you can enumerate the Appointment.Contacts collection to get the contact name and add it too. Be aware though, that an appointment by default can be associated with more than one contact instance, so your code and/or database structure may need to adapt to that.

Regards,
Lyubo

  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: New questions, about localization and value sorting
Reply #28 - Apr 16th, 2014 at 7:36am
Print Post  
Are there any errors in your browser's developer console? It's difficult to guess where the problem may be. Can you paste here the code you use to load the appointments from the database in the calendar?
Or, you can attach here (or send to support@mindfusion.eu) a sample project that reproduces the issue, so that our developer can investigate.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Xylon
Junior Member
**
Offline


I Love MindFusion!

Posts: 96
Joined: Feb 17th, 2014
Re: New questions, about localization and value sorting
Reply #29 - Apr 16th, 2014 at 1:30pm
Print Post  
No errors in console and loading data from database works well, the problem is if I creating a new appointment, it could be stored into datatable but not be displayed on the calendar...

Let me try to figure out...coz there really no error info or other message that I could provide to inspect the error point.

Lyubo wrote on Apr 16th, 2014 at 7:36am:
Are there any errors in your browser's developer console? It's difficult to guess where the problem may be. Can you paste here the code you use to load the appointments from the database in the calendar?
Or, you can attach here (or send to support@mindfusion.eu) a sample project that reproduces the issue, so that our developer can investigate.

Regards,
Lyubo

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 3 
Send TopicPrint