Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Jul 16, 2010 @ 18:09
    Ismail Mayat
    0

    AbstractDataEditor save data xml

    Guys,

    http://www.nibble.be/?p=51 details saving datatype data as xml, however looks like thats not for when you are implmenting AbstractDataEditor interface.  Do you have to do something different in my case i have

    void DataEditorControl_OnSave(EventArgs e)
            {
    
                base.Data.Value = _jquerySheetControl.SheetXml;
            }

     

    wheer SheetXml is string of xml.

    Regards

    Ismail

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Jul 16, 2010 @ 19:02
    Matt Brailsford
    1

    Not sure I entirley understand your question, but here is an example of a data type using the abstractdataeditor that works:

    public class MemberGroupPickerDataType : AbstractDataEditor
        {
            protected MemberGroupPickerControl _control = new MemberGroupPickerControl();

            public MemberGroupPickerDataType()
            {
                _control.Init += new EventHandler(control_Init);

                RenderControl = _control;

                DataEditorControl.OnSave += new AbstractDataEditorControl.SaveEventHandler(DataEditorControl_OnSave);
            }

            public override Guid Id
            {
                get
                {
                    return new Guid("bdbe818d-e088-4caa-9cb8-087494ce73ae");
                }
            }

            public override string DataTypeName
            {
                get
                {
                    return "Member Group Picker";
                }
            }

            protected void control_Init(object sender, EventArgs e)
            {
                _control.InitValue = base.Data.Value as string;
            }

            protected void DataEditorControl_OnSave(EventArgs e)
            {
                base.Data.Value = _control.SelectedValue;
            }
        }

        public class MemberGroupPickerControl : DropDownList
        {
            public string InitValue { get; set; }

            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);

                DataSource = Roles.GetAllRoles();
                DataBind();

                Items.Insert(0, new ListItem(ui.Text("choose") + "...", ""));

                if (!string.IsNullOrEmpty(InitValue))
                    SelectedValue = InitValue;
            }
        }

    Matt

  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    Jul 16, 2010 @ 19:06
    Lee Kelleher
    1

    Hi Ismail,

    As far as I can tell, you'll need to override the PrevalueEditor in your AbstractDataEditor-derived class...

    My_PrevalueEditor m_PreValues;
    
    public override IDataPrevalue PrevalueEditor
    {
        get
        {
            if (m_PreValues == null)
            {
                m_PreValues = new My_PrevalueEditor(this);
            }
    
            return m_PreValues;
        }
    }
    

    Your PrevalueEditor needs to implement the IDataPrevalue interface... then you can set the DBType of the BaseDataType, (to NText).

    Then you can override the Data (of your AbstractDataEditor-derived class) to use a custom DefaultData class - as Tim shows in his blog post.

    Making these customisations seems to take away from the abstraction, but I'm not sure of another way to do it.

    Good luck, and let us know how you get on.

    Cheers, Lee.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies