[CLOSED] Text Align right in fields and gridcolumn

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Text Align right in fields and gridcolumn

    I want
    text-align:right
    for these fields which contain numeric or decimal value,is there any property in InputField or in GridColumn ehere I can set text alignment?

    I use

     .x-grid-cell-inner {
            text-align:right!Important;
        }
    for grid panel ,and all field's text aligned right,but how can I do this for a specific column in grid panel.

    and I use
    X.TextField().Text("20.36").StyleSpec("text-align:right")
    but text not aligned to right.

    what to do?
    Last edited by Daniil; Oct 03, 2014 at 7:17 AM. Reason: [CLOSED]
  2. #2
    Hi @matrixwebtech,

    Do you have TextFields in a GridPanel? Do you use ComponentColumns or, maybe, you mean Editors?

    Please clarify.

    Providing us with a runnable test case is the best way to go.
  3. #3
    Hi Daniil bellow is some sample

      @(
    
                            Html.X().GridPanel()
                            .ID("GridPanel1")
                           .Store(
                            Html.X().Store()
                            .DataSource(ViewBag.loadgrid)
                            .Model
                            (
                            X.Model()
                            .ID("mid")
                           
                            .Fields
                            (
                            X.ModelField().Name("text").Type(ModelFieldType.String),
                             X.ModelField().Name("value").Type(ModelFieldType.Float)
                            )
    
                            )
                            )
                            .ColumnModel(
                           Html.X().Column().DataIndex("text").Text("text").Flex(1).StyleSpec("text-align:right"),
                            Html.X().Column().DataIndex("value").Text("value").Flex(1).StyleSpec("text-align:right")
                             )
                           
                         
                            )
                  
    @(X.TextField().Text("25.36").StyleSpec("text-align:right"))
    @(X.NumberField().Text("25.36").StyleSpec("text-align:right"))
    public class textalignController : Controller
        {
            //
            // GET: /textalign/
    
            public ActionResult Index()
            {
                ViewBag.loadgrid = getSampleData();
                return View();
            }
    
    
            private List<textalign> getSampleData()
            {
                List<textalign> _textalign = new List<textalign>();
                _textalign.Add(new textalign
                {
    
                    text = "Sample text",
                    value = 10.36,
    
                });
                _textalign.Add(new textalign
                {
    
                    text = "some more Sample text",
                    value = 25.38,
    
                });
    
                return _textalign;
            }
        }
    
        public class textalign
        {
            public string text { get; set; }
            public double value { get; set; }
        }
    Q 1.How do set cell's text alignment for grid?i try with
    .StyleSpec("text-align:right")
    for grid column but cell's text alignment not changed,It will change header text alignment.

    Q 2.For TextField or NumberField how do I set text-alignment?
  4. #4
    Please set this for Columns:
    .Align(Alignment.Right)
    http://docs.sencha.com/extjs/4.2.1/#...lumn-cfg-align

    Please use for the TextFields and NumberFields:
    .FieldStyle("text-align:right")
    http://docs.sencha.com/extjs/4.2.1/#...cfg-fieldStyle

    Or the Cls property:
    http://docs.sencha.com/extjs/4.2.1/#...ponent-cfg-cls
  5. #5
    Thank you Daniil,you can close this.

Similar Threads

  1. [CLOSED] Group header align text bottom
    By rthiney in forum 2.x Legacy Premium Help
    Replies: 12
    Last Post: Dec 21, 2013, 9:39 PM
  2. [CLOSED] Icon Align in Text Field
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 13, 2011, 8:50 PM
  3. [CLOSED] Hi how to align the label text to center?
    By Etisbew in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 13, 2009, 11:03 AM
  4. [CLOSED] Text align left for button text
    By macap in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 09, 2009, 10:52 AM
  5. Replies: 1
    Last Post: Jun 18, 2009, 3:27 AM

Posting Permissions