[CLOSED] TagField Code Behind setValue

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] TagField Code Behind setValue

    In the last couple of weeks something has changed in the SVN with the TagField.

    Store used to populate the TagField
    @(
        X.Store()
            .ID("storeDocumentType")
            .AutoLoad(false)
            .AutoDataBind(true)
            .DataSource(Model)
            .Model(
                X.Model()
                    .ID("modelDocumentType")
                    .Fields(
                        X.ModelField().Name("Text").Type(ModelFieldType.String),
                        X.ModelField().Name("Value").Type(ModelFieldType.String)
                    )
            )
    )
    Tag Field definition within a FieldSet
    X.FieldSet()
    .Items(
    .X.TagField().Flex(1).ID("displayRecordDocType").FieldLabel("Doc Type").LabelWidth(70).MultiSelect(true).QueryMode(DataLoadMode.Local)
    .HideTrigger(false).HideSelected(true).Editable(false).TypeAhead(false).StoreID("storeDocumentType").DisplayField("Text").ValueField("Value").GrowMax(100).TagLabelConfig(new TagLabel() { TagsDelimeter = "|", Stacked = true}).Delimiter("|").EmptyText("Select all document types").Listeners(l => { l.Change.Handler = "App.fieldsetBulkSelect.doLayout();"; })
    )
    Originally I had set the following to populate the in code behind the value for the field:
    TagField tf = this.GetCmp<TagField>("displayRecordDocType");
    tf.Clear();
    tf.SetValue(doc.bulkDocTypes);
    Where doc.bulkDoctypes = "Comment|Charts|Solutions"

    After updating to the latest version: 5666, the SetValue no longer works. I have the following with not success:
    Attempt 1:
    tf.Value = doc.bulkDocTypes;
    <-- Does not populate the Tags property
    Attemp 2:
    List<Tag> doctypes = pages.GroupBy(g => new { g.documenttype }).OrderBy(o => o.Key.documenttype).Select(s => new Tag() { Text = s.Key.documenttype, Value = s.Key.documenttype }).ToList();
    tf.Tags.AddRange(doctypes);  <-- Does not populate the Tags property
    Attemp 3:
    List<Tag> doctypes = pages.GroupBy(g => new { g.documenttype }).OrderBy(o => o.Key.documenttype).Select(s => new Tag() { Text = s.Key.documenttype, Value = s.Key.documenttype }).ToList();
    foreach (Tag t in doctypes)
        tf.Tags.Add(t);  <-- Does not populate the Tags property
    What should I be doing to set the Tags value in code behind. I also attempted to remove the store and set the Items property, with no success.
    Thank you for your assistance.
    Russ
    Last edited by Daniil; Feb 17, 2014 at 2:58 AM. Reason: [CLOSED]
  2. #2
    Hi @rsnead,

    You should use either a TagField's Tag or StoreID, but not the both at the same time.
  3. #3
    Thanks Daniil

    I'm using razor format.
    Could you please provider an example of how to use the Store and indicate what is selected? and an example of using the Tags?

    thanks
    Russ
  4. #4
    Sorry, I misled you. You can use StoreID and Tags at the same time.

    Please provide a full sample to reproduce the problem.
  5. #5
    It looks like I reproduced the problem with the SetValue method. We are investigating. Here is a test case.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Set(object sender, DirectEventArgs e)
        {
            Tag[] tags = new Tag[] { new Tag("Jack"), new Tag("Bob") };
            this.TagField1.SetValue(tags);
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Button runat="server" Text="Set" OnDirectClick="Set" />
    
            <ext:TagField ID="TagField1" runat="server" Width="500">
                <Items>
                    <ext:Tag Value="1" Text="Jack" />
                    <ext:Tag Value="2" Text="Bob" />
                    <ext:Tag Value="3" Text="John"  />
                </Items>
            </ext:TagField>
        </form>
    </body>
    </html>
  6. #6
    Thanks Daniil,

    Your example is fairly close to what I am doing. Please let me know when you have an update to the SVN or a solution.

    Thanks
    Russ
  7. #7
    Fixed in SVN. Please update and retest.
    Last edited by Daniil; Feb 17, 2014 at 3:00 AM.
  8. #8
    Thanks Vladimir,

    With the code below, it still is not working as it did before. What modifications to what I am doing would you suggest? If there is an easier, or less complicated setup for the TagField, without the store please let me know.
    Thanks
    Russ


    Store Definition
    @(
    	X.Store()
    		.ID("storeDocumentType")
    		.AutoLoad(false)
    		.AutoDataBind(true)
    		.DataSource(Model)
    		.Model(
    			X.Model()
    				.ID("modelDocumentType")
    				.Fields(
    					X.ModelField().Name("Text").Type(ModelFieldType.String),
    					X.ModelField().Name("Value").Type(ModelFieldType.String)
    				)
    		)
    )
    TagField setup
    X.FieldSet().ID("fieldsetBulkSelect").Border(false).Layout(LayoutType.VBox)
    	.LayoutConfig(new VBoxLayoutConfig { Align = VBoxAlign.Stretch })
    	.Items(
    		X.TagField().Flex(1).ID("displayRecordDocType").FieldLabel("Doc Type").LabelWidth(70).MultiSelect(true)
    		.QueryMode(DataLoadMode.Local)
    		.HideTrigger(false).HideSelected(true).Editable(false).TypeAhead(false)
    		.StoreID("storeDocumentType").DisplayField("Text").ValueField("Value")
    		.GrowMax(100).TagLabelConfig(new TagLabel() { Stacked = true })
    		.Delimiter("|").EmptyText("Select all document types")
    		.Listeners(l => { l.Change.Handler = "App.fieldsetBulkSelect.doLayout();"; })
    		)
    )
    Code Behind
    private void SetBulkSelectStoreData(List<PatientPages> pages)
    {
    	Store storeDocType = this.GetCmp<Store>("storeDocumentType");
    	List<Tag> doctypes = pages
    		.GroupBy(g => new { g.documenttype })
    		.Select(s => new Tag() { Text = s.Key.documenttype, Value = s.Key.documenttype })
    		.OrderBy(o => o.Text).ToList();
    	storeDocType.LoadRawData(doctypes);
    
    	TagField tf = this.GetCmp<TagField>("displayRecordDocType");
    	tf.Clear();
    	string doctypes = string.Join("|", pages.GroupBy(g => new { g.documenttype }).OrderBy(o => o.Key.documenttype).Select(s => s.Key.documenttype).ToArray());
    	tf.SetValue(doctypes);
    
    }
  9. #9
    Please provide runable sample to test the issue
  10. #10
    Thanks Vladimir for assisting me with this issue...

    It is in the code behind that is causing me the issue. Working example below

    View:
    @model System.Collections.IEnumerable 
    @{
        ViewBag.Title = "_tagFieldError";
    		var X = Html.X();
    }
    
    
    
    @(
    	X.Store()
    		.ID("storeDocumentTypeTmp")
    		.AutoLoad(true)
    		.AutoDataBind(true)
    		.DataSource(Model)
    		.LoadProxy(
    			X.AjaxProxy().Url(Url.Action("PopulateStore","Home")).Reader(r => r.Add(X.JsonReader()))
    		)
    		.Model(
    			X.Model()
    				.ID("modelDocumentTypeTmp")
    				.Fields(
    					X.ModelField().Name("Text").Type(ModelFieldType.String),
    					X.ModelField().Name("Value").Type(ModelFieldType.String)
    				)
    		)
    )
    
    @(
    	X.Window()
    		.Width(600)
    		.Height(400)
    		.Modal(true)
    		.BodyPadding(5)
    		.AnchorHorizontal("c")
    		.AnchorVertical("c")
    		.Items(
    					X.FormPanel()
    						.ID("formTagField")
    						.Title("Bulk Select")
    						.Region(Region.Center)
    						.BodyPadding(5)
    						.Height(250)
    						.Collapsible(false)
    						.OverflowY(Overflow.Auto)
    						.Layout(LayoutType.VBox)
    						.LayoutConfig(new VBoxLayoutConfig { Align = VBoxAlign.Stretch })
    						.TopBar(
    							X.Toolbar()
    								.Items(
    									X.Button().Text("Select").Icon(Icon.Find).Handler("App.direct.PopulateStore()"), 									X.ToolbarFill()
    								)
    						)
    						.Items(
    							X.FieldSet().ID("fieldsetBulkSelectTag").Border(false)
    								.Layout(LayoutType.VBox)
    								.LayoutConfig(new VBoxLayoutConfig { Align = VBoxAlign.Stretch })
    								.Items(
    									X.TagField().Flex(1).ID("displayRecordDocTypeTG").FieldLabel("Doc Type").LabelWidth(70).MultiSelect(true).QueryMode(DataLoadMode.Local)
    										.HideTrigger(false).HideSelected(true).Editable(false).TypeAhead(false).StoreID("storeDocumentTypeTmp").DisplayField("Text").ValueField("Value")
    										.GrowMax(100).TagLabelConfig(new TagLabel() { Stacked = true }).Delimiter("|").EmptyText("Select all document types")
    										.Listeners(l => { l.Change.Handler = "App.fieldsetBulkSelect.doLayout();"; })
    									)
    							)
    					)
    
    )

    Code behind
    		public ActionResult RenderTagFieldError()
    		{
    			List<Tag> TagForStore = new List<Tag>();
    			TagForStore.Add(new Tag() { Text = "chart_summary", Value = "chart_summary"});
    			TagForStore.Add(new Tag() { Text = "Growth Chart", Value = "Growth Chart"});
    			TagForStore.Add(new Tag() { Text = "Letter_Labs", Value = "Letter_Labs"});
    			TagForStore.Add(new Tag() { Text = "Paper Chart Authorizations", Value = "Paper Chart Authorizations"});
    			TagForStore.Add(new Tag() { Text = "Paper Chart Correspondence", Value = "Paper Chart Correspondence"});
    			return new Ext.Net.MVC.PartialViewResult { ViewName = "_tagFieldError", Model = TagForStore };
    		}
    		[DirectMethod]
    		public ActionResult PopulateStore()
    		{
    			TagField tf = this.GetCmp<TagField>("displayRecordDocTypeTG");
    			tf.Clear();
    			tf.SetValue("chart_summary|Growth Chart");   <-- At this point, the value is not being set. This was working prior to last update of SVN.
    			return this.Direct();
    		}
    if I use the following it does work. I would prefer to set in code behind.
    X.Toolbar()
    	.Items(
    	X.Button().Text("Select").Icon(Icon.Find).Handler("App.displayRecordDocTypeTG.setValue('chart_summary|Growth Chart')"),
    	X.ToolbarFill()
    )
Page 1 of 2 12 LastLast

Similar Threads

  1. Store not working with TagField
    By GKG4 in forum 2.x Help
    Replies: 5
    Last Post: Feb 13, 2014, 5:20 AM
  2. [CLOSED] Simple Tagfield from Codebehind.
    By waxby in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 06, 2014, 2:51 PM
  3. Replies: 2
    Last Post: Oct 25, 2013, 2:49 AM
  4. Replies: 4
    Last Post: Jul 17, 2013, 2:10 PM
  5. whats wrong in this code ? error in setValue property!
    By jhenriquecosta in forum 2.x Help
    Replies: 1
    Last Post: Jan 29, 2013, 5:06 PM

Posting Permissions