Перенос слов в Out-Gridview - PullRequest
0 голосов
/ 24 апреля 2018

с использованием PowerShell вне сетки. Есть ли способ обернуть текст, чтобы пользователю не приходилось прокручивать, чтобы увидеть все?

Invoke-RestMethod -uri "https://clasd.freshdesk.com/api/v2/tickets? email=xyz@clasd.net" -Headers $FDHeaders -ContentType application/json -Method Get |
    Convertto-json | Out-File C:\csiu\test.txt
$file = "C:\csiu\test.txt"
$data = Get-Content $file -Raw |
    ConvertFrom-Json |
    Select-Object -Expand Value $data |
    Select id, subject, description_text |
    Sort-Object ID |
    Out-GridView -Title "My Tickets" -passthru

Просто хочу, чтобы вид вне сетки обернул текст

Или, если есть другой способ отобразить данные "красивее", я все для этого.

Обновление

Я играл с сеткой данных, и она действительно работает. Единственное, столбцы не имеют правильный размер, или они не изменяют размер самостоятельно. Данный столбец относится к тексту описания.

#Generated Form Function
function GenerateForm {
    ########################################################################
    # Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.8.0
    # Generated On: 4/6/2013 3:10 PM
    # Generated By: jvierra
    ########################################################################

    #region Import the Assemblies
    [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
    [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
    #endregion

    #region Generated Form Objects
    $form1 = New-Object System.Windows.Forms.Form
    $button1 = New-Object System.Windows.Forms.Button
    $dataGrid1 = New-Object System.Windows.Forms.DataGrid
    $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
    #endregion Generated Form Objects

    #----------------------------------------------
    #Generated Event Script Blocks
    #----------------------------------------------
    #Provide Custom Code for events specified in PrimalForms.
    $button1_OnClick= {
    #TODO: Place custom script here

    }
# API Key
$FDApiKey="key"
#################################################

# Force TLS1.2 as Powershell defaults to TLS 1.0 and Freshdesk will fail connections 
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::TLS12

# Prep
$pair = "$($FDApiKey):$($FDApiKey)"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$FDHeaders = @{ Authorization = $basicAuthValue }
##################################################

<#$Body = @{
description = $description.Text
email = $email.Text
subject = $subject.Text
type = $request.Text
priority = 1
status = 2
}#>

Invoke-RestMethod -uri "https://clasd.freshdesk.com/api/v2/tickets?email=mgirt@clasd.net&order_by=status" -Headers $FDHeaders -ContentType application/json -Method Get | Convertto-json | Out-File c:\temp\mytickets.txt
$file = "c:\temp\mytickets.txt"
$data = Get-Content $file -Raw | ConvertFrom-Json | Select-Object -Expand Value


    $handler_form1_Load= 
    {
    $list=[system.collections.arraylist]($data | select id, subject, description_text)
    $datagrid1.DataSource=$list

    }

    $OnLoadForm_StateCorrection=
    {#Correct the initial state of the form to prevent the .Net maximized form issue
        $form1.WindowState = $InitialFormWindowState
    }

    #----------------------------------------------
    #region Generated Form Code
    $form1.Text = "My Tickets"
    $form1.Name = "form1"
    $form1.DataBindings.DefaultDataSourceUpdateMode = 0
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Width = 616
    $System_Drawing_Size.Height = 312
    $form1.ClientSize = $System_Drawing_Size
    $form1.add_Load($handler_form1_Load)

    $button1.TabIndex = 1
    $button1.Name = "button1"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Width = 75
    $System_Drawing_Size.Height = 23
    $button1.Size = $System_Drawing_Size
    $button1.UseVisualStyleBackColor = $False

    $button1.Text = "Ok"

    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 507
    $System_Drawing_Point.Y = 469
    $button1.Location = $System_Drawing_Point
    $button1.DataBindings.DefaultDataSourceUpdateMode = 0
    $button1.DialogResult = 1
    $button1.add_Click($button1_OnClick)

    $form1.Controls.Add($button1)

    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Width = 600
    $System_Drawing_Size.Height = 433
    $dataGrid1.Size = $System_Drawing_Size
    $dataGrid1.DataBindings.DefaultDataSourceUpdateMode = 0
    $dataGrid1.HeaderForeColor = [System.Drawing.Color]::FromArgb(255,0,0,0)
    $dataGrid1.Name = "dataGrid1"
    $dataGrid1.DataMember = ""
    $dataGrid1.TabIndex = 0
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 1
    $System_Drawing_Point.Y = 12
    $dataGrid1.Location = $System_Drawing_Point

    $form1.Controls.Add($dataGrid1)

    #endregion Generated Form Code

    #Save the initial state of the form
    $InitialFormWindowState = $form1.WindowState
    #Init the OnLoad event to correct the initial state of the form
    $form1.add_Load($OnLoadForm_StateCorrection)
    #Show the Form
    $form1.ShowDialog()| Out-Null

} #End Function

#Call the Function
GenerateForm
...