Giter Site home page Giter Site logo

Disable headers? about tabled HOT 12 CLOSED

zhiburt avatar zhiburt commented on June 10, 2024 1
Disable headers?

from tabled.

Comments (12)

zhiburt avatar zhiburt commented on June 10, 2024 1

Hi @numToStr, appreciate your words, thank you
It's an interesting case there's no such an option currently but I certainly can work on it.

PS: Just publish a option for disabling columns via attributes.

        #[derive(Tabled)]
        enum Letters {
            Vowels {
                character: char,
                lang: u8,
            },
            Consonant(char),
            #[header(hidden)]
            Digit,
        }

from tabled.

numToStr avatar numToStr commented on June 10, 2024 1

@zhiburt Thank you so much. v.0.1.3 does solve my use case.

Here is the final code

  • Code
#[derive(Tabled)]
struct Detail(&'static str, String);

let details = [
    Detail("Username", "username".to_string()),
    Detail("Password", "password".to_string()),
    Detail("URL", "url".to_string()),
    Detail("Notes", "notes".to_string()),
];

let table = table!(
    &details,
    Disable::Row(..1),
    Style::pseudo_clean().header(None),
    HorizontalAlignment(Row(..), Alignment::Left),
    Format(Row(..), |s| format!(" {} ", s))
);

print!("{}", table);
  • Output
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Username β”‚ username β”‚
β”‚ Password β”‚ password β”‚
β”‚ URL      β”‚ url      β”‚
β”‚ Notes    β”‚ notes    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

I'll now close the issue.

from tabled.

numToStr avatar numToStr commented on June 10, 2024

Woah, that's fast. Thanks for your hardwork.

So, is it published on crates?

from tabled.

zhiburt avatar zhiburt commented on June 10, 2024

So, is it published on crates?

Not yet, planning later this day as there's a couple more things to tackle.

from tabled.

numToStr avatar numToStr commented on June 10, 2024

Thanks for letting me know. Waiting for the next release ✌🏻.

from tabled.

zhiburt avatar zhiburt commented on June 10, 2024

I've add a Dissable setting which partially solves the problem.

According to a style I'll inspect some ways to bypass this and return with the answer.

fn dissable_header() {
let data = vec![
Linux {
id: 0,
destribution: "Fedora",
link: "https://getfedora.org/",
},
Linux {
id: 2,
destribution: "OpenSUSE",
link: "https://www.opensuse.org/",
},
Linux {
id: 3,
destribution: "Endeavouros",
link: "https://endeavouros.com/",
},
];
let expected = concat!(
"0|Fedora |https://getfedora.org/ \n",
"2|OpenSUSE |https://www.opensuse.org/\n",
"3|Endeavouros|https://endeavouros.com/ \n",
);
let table = table!(
&data,
Style::Psql,
HorizontalAlignment(Full, Alignment::Left),
Dissable::Row(..1),
);
assert_eq!(table, expected);
}

from tabled.

numToStr avatar numToStr commented on June 10, 2024

Just saw the test and I think Dissable::Row(..1) solves the use case.

Off topic: Why did you name it Dissable not Disable?

from tabled.

zhiburt avatar zhiburt commented on June 10, 2024

Just saw the test and I think Dissable::Row(..1) solves the use case.

It is the only thing is a different look of a first row.

Off topic: Why did you name it Dissable not Disable?

Clearly misspell it πŸ€• .
Already fixed. Good catch.

from tabled.

zhiburt avatar zhiburt commented on June 10, 2024

I've just published customization for Style.
And getting back to your example now you can achieve it by combining custom styles + disable.

    let table = table!(
        &data,
        HorizontalAlignment(Full, Alignment::Left),
        Disable::Row(..1),
        Style::pseudo_clean().header(None),
    );

Output

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚Usernameβ”‚usernameβ”‚
β”‚Passwordβ”‚passwordβ”‚
β”‚URL     β”‚url     β”‚
β”‚Notes   β”‚notes   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜

@numToStr please mark an issue as resolved if you think it is.

from tabled.

numToStr avatar numToStr commented on June 10, 2024

Thanks for the update. I'll try the new release and report back.

from tabled.

numToStr avatar numToStr commented on June 10, 2024

@zhiburt Did you publish the update?

from tabled.

zhiburt avatar zhiburt commented on June 10, 2024

@zhiburt Did you publish the update?

It's supposed to be in a few minutes

from tabled.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.