An easier approach for using the Editor?

An easier approach for using the Editor?

dwlanghamdwlangham Posts: 2Questions: 1Answers: 0

I downloaded the demo of the Editor extension for .NET. I'm impressed by how it works, but it's way more than I was expecting. Looking at the examples it looks like I have to replace what I'm doing already with MVC and Entity Framework. That part of my project works fine. What I need is an easy way to edit table data. I expected more functionality in the Javascript code, not more complexity in my .NET code.

Am I missing something?

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Editor is primarily a client-side library. We provide server-side libraries for .NET (not EF), NodeJS and PHP for those who don't want to write their own database interaction code, but it is absolutely possible (and designed to be) to use the client-side code without the provided libraries.

    The client / server data interchange is fully documented here and I'm happy to answer any questions you have about it.

    Allan

  • dwlanghamdwlangham Posts: 2Questions: 1Answers: 0

    Allan:

    I'm having difficulty getting the keys and values from the data object that my controller receives via POST from the html containing the Editor.

    I'm trying to use the DtRequest object from the .NET dll. I've tried submitting Request.Form to the constructor (System.Web.HttpContext.Current.Request.Form), which is of type NameValueCollection. Visual Studio complains that it can't convert from Systems.Specialized.Collections.NameValueCollection to Systems.Collections.Generic.IEnumerable<Systems.Collections.Generic.KeyValuePair<string, string>>'.

    What am I missing?

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Yes, I'm afraid you'd need to convert it into a suitable object. This is the function that is used in the Editor.cs file to do that:

            /// <summary>
            /// Process a request from the Editor client-side to get / set data.
            /// For use with MVC's 'Request.Form' collection
            /// </summary>
            /// <param name="data">Data sent from the client-side</param>
            /// <returns>Self for chaining</returns>
            public Editor Process(NameValueCollection data = null)
            {
                var list = new List<KeyValuePair<string, string>>();
    
                if (data != null)
                {
                    foreach (var key in data.AllKeys)
                    {
                        list.Add(new KeyValuePair<string, string>(key, data[key]));
                    }
                }
    
                return Process(new DtRequest(list));
            }
    

    Allan

This discussion has been closed.