У меня есть сетка, данные которой взяты из json.
Json:
"error": false,
"total_data": 210,
"data_per_page": "200",
"current_page": 1,
"total_page": 2,
"current_total": 200,
"data": [
{
"id": "3415",
"judul": "",
"slug": "",
"cover": "",
"path": "https://..../dl/dodl/3415",
"ukuran": "0",
"formated_size": "0.00 Bytes",
"fname": "",
"publish": "1",
"urgent": "0",
"kelas": "0",
"nama_kelas": "Umum"
},
{
"id": "3410",
"judul": "Ukuran",
"slug": "ukuran",
"cover": "https://..../cover/MjEwLnVrdXJhbl90a19wLmpwZw__.jpg",
"path": "https://.../dl/dodl/3410",
"ukuran": "4687432",
"formated_size": "4.47 MB",
"fname": "MjEwLnVrdXJhbl90ay5wZGY_.pdf",
"publish": "1",
"urgent": "0",
"kelas": "14",
"nama_kelas": "TK"
},
{
Код:
try
{
string urlPath1 = "https://.../fetch/komik";
var httpClient1 = new HttpClient(new HttpClientHandler());
var values1 = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("halaman", "1"),
new KeyValuePair<string, string>("limit", "20"),
new KeyValuePair<string, string>("SCH-API-KEY", "SCH_KEnaBiDeplebt")
};
var response1 = await httpClient1.PostAsync(urlPath1, new FormUrlEncodedContent(values1));
response1.EnsureSuccessStatusCode();
string jsonText1 = await response1.Content.ReadAsStringAsync();
JsonObject jsonObject1 = JsonObject.Parse(jsonText1);
JsonArray jsonData1 = jsonObject1["data"].GetArray();
foreach (JsonValue groupValue1 in jsonData1)
{
JsonObject groupObject2 = groupValue1.GetObject();
string id = groupObject2["id"].GetString();
string title = groupObject2["judul"].GetString();
string cover = groupObject2["cover"].GetString();
string file_path = groupObject2["path"].GetString();
string size = groupObject2["formated_size"].GetString();
string slug = groupObject2["slug"].GetString();
Buku file1 = new Buku();
file1.ID = id;
file1.Judul = title;
file1.Cover = cover;
file1.File = file_path;
file1.Size = size;
file1.Slug = slug + ".pdf";
if (file1.Size != "0.00 Bytes" || file1.Name != "" || file1.Name != null)
{
datasource.Add(file1);
}
}
itemGridView.ItemsSource = datasource;
}
catch (HttpRequestException ex)
{
busyindicator.IsActive = false;
loading.Visibility = Visibility.Collapsed;
RequestException();
}
private void RequestException()
{
requestErrorStack.Visibility = Visibility.Visible;
}
У меня проблема с моим кодом выше, но с данными formated_size = "0.00 Bytes" или title = "" данные все еще отображаются в виде сетки. Я хочу, если formated_size = "0,00 байт" или title = "", то данные не отображаются в виде сетки.
Как вы это исправите?